Skip to content

Commit d05668d

Browse files
committed
child_process: runtime deprecate _channel
This commit moves DEP0129 to a runtime deprecation. PR-URL: #27949 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 80d9b1c commit d05668d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2436,12 +2436,15 @@ Node.js versions.
24362436
### DEP0129: ChildProcess._channel
24372437
<!-- YAML
24382438
changes:
2439+
- version: REPLACEME
2440+
pr-url: https://github.com/nodejs/node/pull/27949
2441+
description: Runtime deprecation.
24392442
- version: v11.14.0
24402443
pr-url: https://github.com/nodejs/node/pull/26982
24412444
description: Documentation-only.
24422445
-->
24432446
2444-
Type: Documentation-only
2447+
Type: Runtime
24452448
24462449
The `_channel` property of child process objects returned by `spawn()` and
24472450
similar functions is not intended for public use. Use `ChildProcess.channel`

lib/internal/child_process.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const { TTY } = internalBinding('tty_wrap');
3737
const { UDP } = internalBinding('udp_wrap');
3838
const SocketList = require('internal/socket_list');
3939
const { owner_symbol } = require('internal/async_hooks').symbols;
40-
const { convertToValidSignal } = require('internal/util');
40+
const { convertToValidSignal, deprecate } = require('internal/util');
4141
const { isArrayBufferView } = require('internal/util/types');
4242
const spawn_sync = internalBinding('spawn_sync');
4343
const { kStateSymbol } = require('internal/dgram');
@@ -513,14 +513,21 @@ class Control extends EventEmitter {
513513
}
514514
}
515515

516+
const channelDeprecationMsg = '_channel is deprecated. ' +
517+
'Use ChildProcess.channel instead.';
518+
516519
function setupChannel(target, channel) {
517520
target.channel = channel;
518521

519-
// _channel can be deprecated in version 8
520522
Object.defineProperty(target, '_channel', {
521-
get() { return target.channel; },
522-
set(val) { target.channel = val; },
523-
enumerable: true
523+
get: deprecate(() => {
524+
return target.channel;
525+
}, channelDeprecationMsg, 'DEP0129'),
526+
set: deprecate((val) => {
527+
target.channel = val;
528+
}, channelDeprecationMsg, 'DEP0129'),
529+
configurable: true,
530+
enumerable: false
524531
});
525532

526533
target._handleQueue = null;

0 commit comments

Comments
 (0)