mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
dgram: move deprecated APIs to EOL
Seven years is long enough to be deprecated. PR-URL: https://github.com/nodejs/node/pull/58474 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
705bcc2a00
commit
968e2f47c8
4 changed files with 7 additions and 162 deletions
|
@ -2394,19 +2394,22 @@ unavailable when the [permission model][] is enabled.
|
||||||
|
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/58474
|
||||||
|
description: End-of-Life.
|
||||||
- version: v11.0.0
|
- version: v11.0.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/22011
|
pr-url: https://github.com/nodejs/node/pull/22011
|
||||||
description: Runtime deprecation.
|
description: Runtime deprecation.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Type: Runtime
|
Type: End-of-Life
|
||||||
|
|
||||||
The `node:dgram` module previously contained several APIs that were never meant
|
The `node:dgram` module previously contained several APIs that were never meant
|
||||||
to accessed outside of Node.js core: `Socket.prototype._handle`,
|
to accessed outside of Node.js core: `Socket.prototype._handle`,
|
||||||
`Socket.prototype._receiving`, `Socket.prototype._bindState`,
|
`Socket.prototype._receiving`, `Socket.prototype._bindState`,
|
||||||
`Socket.prototype._queue`, `Socket.prototype._reuseAddr`,
|
`Socket.prototype._queue`, `Socket.prototype._reuseAddr`,
|
||||||
`Socket.prototype._healthCheck()`, `Socket.prototype._stopReceiving()`, and
|
`Socket.prototype._healthCheck()`, `Socket.prototype._stopReceiving()`, and
|
||||||
`dgram._createSocketHandle()`.
|
`dgram._createSocketHandle()`. These have been removed.
|
||||||
|
|
||||||
### DEP0113: `Cipher.setAuthTag()`, `Decipher.getAuthTag()`
|
### DEP0113: `Cipher.setAuthTag()`, `Decipher.getAuthTag()`
|
||||||
|
|
||||||
|
|
75
lib/dgram.js
75
lib/dgram.js
|
@ -53,7 +53,6 @@ const {
|
||||||
} = require('internal/errors');
|
} = require('internal/errors');
|
||||||
const {
|
const {
|
||||||
kStateSymbol,
|
kStateSymbol,
|
||||||
_createSocketHandle,
|
|
||||||
newHandle,
|
newHandle,
|
||||||
} = require('internal/dgram');
|
} = require('internal/dgram');
|
||||||
const { isIP } = require('internal/net');
|
const { isIP } = require('internal/net');
|
||||||
|
@ -66,7 +65,7 @@ const {
|
||||||
validateUint32,
|
validateUint32,
|
||||||
} = require('internal/validators');
|
} = require('internal/validators');
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const { deprecate, guessHandleType, promisify } = require('internal/util');
|
const { guessHandleType, promisify } = require('internal/util');
|
||||||
const { isArrayBufferView } = require('internal/util/types');
|
const { isArrayBufferView } = require('internal/util/types');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const { addAbortListener } = require('internal/events/abort_listener');
|
const { addAbortListener } = require('internal/events/abort_listener');
|
||||||
|
@ -1044,72 +1043,6 @@ Socket.prototype.getSendQueueCount = function() {
|
||||||
return this[kStateSymbol].handle.getSendQueueCount();
|
return this[kStateSymbol].handle.getSendQueueCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Deprecated private APIs.
|
|
||||||
ObjectDefineProperty(Socket.prototype, '_handle', {
|
|
||||||
__proto__: null,
|
|
||||||
get: deprecate(function() {
|
|
||||||
return this[kStateSymbol].handle;
|
|
||||||
}, 'Socket.prototype._handle is deprecated', 'DEP0112'),
|
|
||||||
set: deprecate(function(val) {
|
|
||||||
this[kStateSymbol].handle = val;
|
|
||||||
}, 'Socket.prototype._handle is deprecated', 'DEP0112'),
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ObjectDefineProperty(Socket.prototype, '_receiving', {
|
|
||||||
__proto__: null,
|
|
||||||
get: deprecate(function() {
|
|
||||||
return this[kStateSymbol].receiving;
|
|
||||||
}, 'Socket.prototype._receiving is deprecated', 'DEP0112'),
|
|
||||||
set: deprecate(function(val) {
|
|
||||||
this[kStateSymbol].receiving = val;
|
|
||||||
}, 'Socket.prototype._receiving is deprecated', 'DEP0112'),
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ObjectDefineProperty(Socket.prototype, '_bindState', {
|
|
||||||
__proto__: null,
|
|
||||||
get: deprecate(function() {
|
|
||||||
return this[kStateSymbol].bindState;
|
|
||||||
}, 'Socket.prototype._bindState is deprecated', 'DEP0112'),
|
|
||||||
set: deprecate(function(val) {
|
|
||||||
this[kStateSymbol].bindState = val;
|
|
||||||
}, 'Socket.prototype._bindState is deprecated', 'DEP0112'),
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ObjectDefineProperty(Socket.prototype, '_queue', {
|
|
||||||
__proto__: null,
|
|
||||||
get: deprecate(function() {
|
|
||||||
return this[kStateSymbol].queue;
|
|
||||||
}, 'Socket.prototype._queue is deprecated', 'DEP0112'),
|
|
||||||
set: deprecate(function(val) {
|
|
||||||
this[kStateSymbol].queue = val;
|
|
||||||
}, 'Socket.prototype._queue is deprecated', 'DEP0112'),
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ObjectDefineProperty(Socket.prototype, '_reuseAddr', {
|
|
||||||
__proto__: null,
|
|
||||||
get: deprecate(function() {
|
|
||||||
return this[kStateSymbol].reuseAddr;
|
|
||||||
}, 'Socket.prototype._reuseAddr is deprecated', 'DEP0112'),
|
|
||||||
set: deprecate(function(val) {
|
|
||||||
this[kStateSymbol].reuseAddr = val;
|
|
||||||
}, 'Socket.prototype._reuseAddr is deprecated', 'DEP0112'),
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Socket.prototype._healthCheck = deprecate(function() {
|
|
||||||
healthCheck(this);
|
|
||||||
}, 'Socket.prototype._healthCheck() is deprecated', 'DEP0112');
|
|
||||||
|
|
||||||
|
|
||||||
Socket.prototype._stopReceiving = deprecate(function() {
|
|
||||||
stopReceiving(this);
|
|
||||||
}, 'Socket.prototype._stopReceiving() is deprecated', 'DEP0112');
|
|
||||||
|
|
||||||
|
|
||||||
// Legacy alias on the C++ wrapper object. This is not public API, so we may
|
// Legacy alias on the C++ wrapper object. This is not public API, so we may
|
||||||
// want to runtime-deprecate it at some point. There's no hurry, though.
|
// want to runtime-deprecate it at some point. There's no hurry, though.
|
||||||
ObjectDefineProperty(UDP.prototype, 'owner', {
|
ObjectDefineProperty(UDP.prototype, 'owner', {
|
||||||
|
@ -1118,13 +1051,7 @@ ObjectDefineProperty(UDP.prototype, 'owner', {
|
||||||
set(v) { return this[owner_symbol] = v; },
|
set(v) { return this[owner_symbol] = v; },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
_createSocketHandle: deprecate(
|
|
||||||
_createSocketHandle,
|
|
||||||
'dgram._createSocketHandle() is deprecated',
|
|
||||||
'DEP0112',
|
|
||||||
),
|
|
||||||
createSocket,
|
createSocket,
|
||||||
Socket,
|
Socket,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,11 +5,10 @@ if (common.isWindows)
|
||||||
common.skip('Does not support binding fd on Windows');
|
common.skip('Does not support binding fd on Windows');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const dgram = require('dgram');
|
const { _createSocketHandle } = require('internal/dgram');
|
||||||
const { internalBinding } = require('internal/test/binding');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
const { UDP } = internalBinding('udp_wrap');
|
const { UDP } = internalBinding('udp_wrap');
|
||||||
const { TCP, constants } = internalBinding('tcp_wrap');
|
const { TCP, constants } = internalBinding('tcp_wrap');
|
||||||
const _createSocketHandle = dgram._createSocketHandle;
|
|
||||||
|
|
||||||
// Return a negative number if the "existing fd" is invalid.
|
// Return a negative number if the "existing fd" is invalid.
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const common = require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const dgram = require('dgram');
|
|
||||||
const fork = require('child_process').fork;
|
|
||||||
|
|
||||||
const sock = dgram.createSocket('udp4');
|
|
||||||
|
|
||||||
const testNumber = parseInt(process.argv[2], 10);
|
|
||||||
|
|
||||||
const propertiesToTest = [
|
|
||||||
'_handle',
|
|
||||||
'_receiving',
|
|
||||||
'_bindState',
|
|
||||||
'_queue',
|
|
||||||
'_reuseAddr',
|
|
||||||
];
|
|
||||||
|
|
||||||
const methodsToTest = [
|
|
||||||
'_healthCheck',
|
|
||||||
'_stopReceiving',
|
|
||||||
];
|
|
||||||
|
|
||||||
const propertyCases = propertiesToTest.map((propName) => {
|
|
||||||
return [
|
|
||||||
() => {
|
|
||||||
// Test property getter
|
|
||||||
common.expectWarning(
|
|
||||||
'DeprecationWarning',
|
|
||||||
`Socket.prototype.${propName} is deprecated`,
|
|
||||||
'DEP0112'
|
|
||||||
);
|
|
||||||
sock[propName]; // eslint-disable-line no-unused-expressions
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
// Test property setter
|
|
||||||
common.expectWarning(
|
|
||||||
'DeprecationWarning',
|
|
||||||
`Socket.prototype.${propName} is deprecated`,
|
|
||||||
'DEP0112'
|
|
||||||
);
|
|
||||||
sock[propName] = null;
|
|
||||||
},
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
const methodCases = methodsToTest.map((propName) => {
|
|
||||||
return () => {
|
|
||||||
common.expectWarning(
|
|
||||||
'DeprecationWarning',
|
|
||||||
`Socket.prototype.${propName}() is deprecated`,
|
|
||||||
'DEP0112'
|
|
||||||
);
|
|
||||||
sock[propName]();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const cases = [].concat(
|
|
||||||
...propertyCases,
|
|
||||||
...methodCases
|
|
||||||
);
|
|
||||||
|
|
||||||
// If we weren't passed a test ID then we need to spawn all of the cases.
|
|
||||||
// We run the cases in child processes since deprecations print once.
|
|
||||||
if (Number.isNaN(testNumber)) {
|
|
||||||
const children = cases.map((_case, i) =>
|
|
||||||
fork(process.argv[1], [ String(i) ]));
|
|
||||||
|
|
||||||
children.forEach((child) => {
|
|
||||||
child.on('close', (code) => {
|
|
||||||
// Pass on child exit code
|
|
||||||
if (code > 0) {
|
|
||||||
process.exit(code);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We were passed a test ID - run the test case
|
|
||||||
assert.ok(cases[testNumber]);
|
|
||||||
cases[testNumber]();
|
|
Loading…
Add table
Add a link
Reference in a new issue