From a16ce0e363f8212a2305b558ed996cbb25d864b5 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sat, 31 May 2025 09:14:19 -0700 Subject: [PATCH 1/2] child_process: move _channel to end-of-life The `._channel` property has been deprecated for many years now. It's time to remove it. --- doc/api/deprecations.md | 5 ++++- lib/internal/child_process.js | 18 +----------------- test/parallel/test-child-process-fork.js | 2 -- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index c0f762c54860a6..cbbca17f936780 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2705,6 +2705,9 @@ Node.js versions. -Type: Runtime +Type: End-of-Life The `_channel` property of child process objects returned by `spawn()` and similar functions is not intended for public use. Use `ChildProcess.channel` diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index dada6b8cc5a1fd..f110557a9374f7 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -7,7 +7,6 @@ const { ArrayPrototypeSlice, FunctionPrototype, FunctionPrototypeCall, - ObjectDefineProperty, ObjectSetPrototypeOf, ReflectApply, StringPrototypeSlice, @@ -56,7 +55,7 @@ const { TTY } = internalBinding('tty_wrap'); const { UDP } = internalBinding('udp_wrap'); const SocketList = require('internal/socket_list'); const { owner_symbol } = require('internal/async_hooks').symbols; -const { convertToValidSignal, deprecate } = require('internal/util'); +const { convertToValidSignal } = require('internal/util'); const { isArrayBufferView } = require('internal/util/types'); const spawn_sync = internalBinding('spawn_sync'); const { kStateSymbol } = require('internal/dgram'); @@ -575,27 +574,12 @@ class Control extends EventEmitter { } } -const channelDeprecationMsg = '_channel is deprecated. ' + - 'Use ChildProcess.channel instead.'; - let serialization; function setupChannel(target, channel, serializationMode) { const control = new Control(channel); target.channel = control; target[kChannelHandle] = channel; - ObjectDefineProperty(target, '_channel', { - __proto__: null, - get: deprecate(() => { - return target.channel; - }, channelDeprecationMsg, 'DEP0129'), - set: deprecate((val) => { - target.channel = val; - }, channelDeprecationMsg, 'DEP0129'), - configurable: true, - enumerable: false, - }); - target._handleQueue = null; target._pendingMessage = null; diff --git a/test/parallel/test-child-process-fork.js b/test/parallel/test-child-process-fork.js index a357f4fbc192ef..ee9dd3fc9f4746 100644 --- a/test/parallel/test-child-process-fork.js +++ b/test/parallel/test-child-process-fork.js @@ -18,7 +18,6 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -// Flags: --no-warnings 'use strict'; const common = require('../common'); const assert = require('assert'); @@ -29,7 +28,6 @@ const debug = require('util').debuglog('test'); const n = fork(fixtures.path('child-process-spawn-node.js'), args); -assert.strictEqual(n.channel, n._channel); assert.deepStrictEqual(args, ['foo', 'bar']); n.on('message', (m) => { From e248f99018040512dc2884cade04d8726ce749d6 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sat, 31 May 2025 09:28:57 -0700 Subject: [PATCH 2/2] Update doc/api/deprecations.md --- doc/api/deprecations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index cbbca17f936780..373b192fe20e28 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2706,7 +2706,7 @@ Node.js versions.