Skip to content

Commit fe069cc

Browse files
committed
dgram: deprecate all previous private APIs
PR-URL: #22011 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 0b85435 commit fe069cc

File tree

2 files changed

+42
-26
lines changed

2 files changed

+42
-26
lines changed

doc/api/deprecations.md

+12
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,18 @@ Type: Documentation-only
10091009
The `process.binding()` API is intended for use by Node.js internal code
10101010
only. Use of `process.binding()` by userland code is unsupported.
10111011
1012+
<a id="DEP0112"></a>
1013+
### DEP0112: dgram private APIs
1014+
1015+
Type: Runtime
1016+
1017+
The `dgram` module previously contained several APIs that were never meant to
1018+
accessed outside of Node.js core: `Socket.prototype._handle`,
1019+
`Socket.prototype._receiving`, `Socket.prototype._bindState`,
1020+
`Socket.prototype._queue`, `Socket.prototype._reuseAddr`,
1021+
`Socket.prototype._healthCheck()`, `Socket.prototype._stopReceiving()`, and
1022+
`dgram._createSocketHandle()`.
1023+
10121024
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
10131025
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
10141026
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array

lib/dgram.js

+30-26
Original file line numberDiff line numberDiff line change
@@ -737,65 +737,65 @@ Socket.prototype.getSendBufferSize = function() {
737737
};
738738

739739

740-
// Legacy private APIs to be deprecated in the future.
740+
// Deprecated private APIs.
741741
Object.defineProperty(Socket.prototype, '_handle', {
742-
get() {
742+
get: util.deprecate(function() {
743743
return this[kStateSymbol].handle;
744-
},
745-
set(val) {
744+
}, 'Socket.prototype._handle is deprecated', 'DEP0112'),
745+
set: util.deprecate(function(val) {
746746
this[kStateSymbol].handle = val;
747-
}
747+
}, 'Socket.prototype._handle is deprecated', 'DEP0112')
748748
});
749749

750750

751751
Object.defineProperty(Socket.prototype, '_receiving', {
752-
get() {
752+
get: util.deprecate(function() {
753753
return this[kStateSymbol].receiving;
754-
},
755-
set(val) {
754+
}, 'Socket.prototype._receiving is deprecated', 'DEP0112'),
755+
set: util.deprecate(function(val) {
756756
this[kStateSymbol].receiving = val;
757-
}
757+
}, 'Socket.prototype._receiving is deprecated', 'DEP0112')
758758
});
759759

760760

761761
Object.defineProperty(Socket.prototype, '_bindState', {
762-
get() {
762+
get: util.deprecate(function() {
763763
return this[kStateSymbol].bindState;
764-
},
765-
set(val) {
764+
}, 'Socket.prototype._bindState is deprecated', 'DEP0112'),
765+
set: util.deprecate(function(val) {
766766
this[kStateSymbol].bindState = val;
767-
}
767+
}, 'Socket.prototype._bindState is deprecated', 'DEP0112')
768768
});
769769

770770

771771
Object.defineProperty(Socket.prototype, '_queue', {
772-
get() {
772+
get: util.deprecate(function() {
773773
return this[kStateSymbol].queue;
774-
},
775-
set(val) {
774+
}, 'Socket.prototype._queue is deprecated', 'DEP0112'),
775+
set: util.deprecate(function(val) {
776776
this[kStateSymbol].queue = val;
777-
}
777+
}, 'Socket.prototype._queue is deprecated', 'DEP0112')
778778
});
779779

780780

781781
Object.defineProperty(Socket.prototype, '_reuseAddr', {
782-
get() {
782+
get: util.deprecate(function() {
783783
return this[kStateSymbol].reuseAddr;
784-
},
785-
set(val) {
784+
}, 'Socket.prototype._reuseAddr is deprecated', 'DEP0112'),
785+
set: util.deprecate(function(val) {
786786
this[kStateSymbol].reuseAddr = val;
787-
}
787+
}, 'Socket.prototype._reuseAddr is deprecated', 'DEP0112')
788788
});
789789

790790

791-
Socket.prototype._healthCheck = function() {
791+
Socket.prototype._healthCheck = util.deprecate(function() {
792792
healthCheck(this);
793-
};
793+
}, 'Socket.prototype._healthCheck() is deprecated', 'DEP0112');
794794

795795

796-
Socket.prototype._stopReceiving = function() {
796+
Socket.prototype._stopReceiving = util.deprecate(function() {
797797
stopReceiving(this);
798-
};
798+
}, 'Socket.prototype._stopReceiving() is deprecated', 'DEP0112');
799799

800800

801801
// Legacy alias on the C++ wrapper object. This is not public API, so we may
@@ -807,7 +807,11 @@ Object.defineProperty(UDP.prototype, 'owner', {
807807

808808

809809
module.exports = {
810-
_createSocketHandle,
810+
_createSocketHandle: util.deprecate(
811+
_createSocketHandle,
812+
'dgram._createSocketHandle() is deprecated',
813+
'DEP0112'
814+
),
811815
createSocket,
812816
Socket
813817
};

0 commit comments

Comments
 (0)