From 968e2f47c89d42205640f13342ab8b89ff312fe0 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 30 May 2025 19:59:40 -0700 Subject: [PATCH] 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 Reviewed-By: Marco Ippolito Reviewed-By: Matteo Collina Reviewed-By: Filip Skokan Reviewed-By: Luigi Pinca --- doc/api/deprecations.md | 7 +- lib/dgram.js | 75 +---------------- .../test-dgram-create-socket-handle-fd.js | 3 +- test/parallel/test-dgram-deprecation-error.js | 84 ------------------- 4 files changed, 7 insertions(+), 162 deletions(-) delete mode 100644 test/parallel/test-dgram-deprecation-error.js diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 7bfd06e6997..cbaaef04f59 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2394,19 +2394,22 @@ unavailable when the [permission model][] is enabled. -Type: Runtime +Type: End-of-Life The `node:dgram` module previously contained several APIs that were never meant to accessed outside of Node.js core: `Socket.prototype._handle`, `Socket.prototype._receiving`, `Socket.prototype._bindState`, `Socket.prototype._queue`, `Socket.prototype._reuseAddr`, `Socket.prototype._healthCheck()`, `Socket.prototype._stopReceiving()`, and -`dgram._createSocketHandle()`. +`dgram._createSocketHandle()`. These have been removed. ### DEP0113: `Cipher.setAuthTag()`, `Decipher.getAuthTag()` diff --git a/lib/dgram.js b/lib/dgram.js index 163f2139e7a..95184035a53 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -53,7 +53,6 @@ const { } = require('internal/errors'); const { kStateSymbol, - _createSocketHandle, newHandle, } = require('internal/dgram'); const { isIP } = require('internal/net'); @@ -66,7 +65,7 @@ const { validateUint32, } = require('internal/validators'); const { Buffer } = require('buffer'); -const { deprecate, guessHandleType, promisify } = require('internal/util'); +const { guessHandleType, promisify } = require('internal/util'); const { isArrayBufferView } = require('internal/util/types'); const EventEmitter = require('events'); const { addAbortListener } = require('internal/events/abort_listener'); @@ -1044,72 +1043,6 @@ Socket.prototype.getSendQueueCount = function() { 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 // want to runtime-deprecate it at some point. There's no hurry, though. ObjectDefineProperty(UDP.prototype, 'owner', { @@ -1118,13 +1051,7 @@ ObjectDefineProperty(UDP.prototype, 'owner', { set(v) { return this[owner_symbol] = v; }, }); - module.exports = { - _createSocketHandle: deprecate( - _createSocketHandle, - 'dgram._createSocketHandle() is deprecated', - 'DEP0112', - ), createSocket, Socket, }; diff --git a/test/parallel/test-dgram-create-socket-handle-fd.js b/test/parallel/test-dgram-create-socket-handle-fd.js index 93175859c19..ed7fb9ae1b9 100644 --- a/test/parallel/test-dgram-create-socket-handle-fd.js +++ b/test/parallel/test-dgram-create-socket-handle-fd.js @@ -5,11 +5,10 @@ if (common.isWindows) common.skip('Does not support binding fd on Windows'); const assert = require('assert'); -const dgram = require('dgram'); +const { _createSocketHandle } = require('internal/dgram'); const { internalBinding } = require('internal/test/binding'); const { UDP } = internalBinding('udp_wrap'); const { TCP, constants } = internalBinding('tcp_wrap'); -const _createSocketHandle = dgram._createSocketHandle; // Return a negative number if the "existing fd" is invalid. { diff --git a/test/parallel/test-dgram-deprecation-error.js b/test/parallel/test-dgram-deprecation-error.js deleted file mode 100644 index c544a917b02..00000000000 --- a/test/parallel/test-dgram-deprecation-error.js +++ /dev/null @@ -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]();