From d05668d6884992765e94cec2ba755feb946071c1 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 29 May 2019 09:22:52 -0400 Subject: [PATCH] child_process: runtime deprecate _channel This commit moves DEP0129 to a runtime deprecation. PR-URL: https://github.com/nodejs/node/pull/27949 Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- doc/api/deprecations.md | 5 ++++- lib/internal/child_process.js | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 41070fe145c25e..284df5a2886c5f 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2436,12 +2436,15 @@ Node.js versions. ### DEP0129: ChildProcess._channel -Type: Documentation-only +Type: Runtime 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 71eeed2994fbde..67687e1a07a460 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -37,7 +37,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 } = require('internal/util'); +const { convertToValidSignal, deprecate } = require('internal/util'); const { isArrayBufferView } = require('internal/util/types'); const spawn_sync = internalBinding('spawn_sync'); const { kStateSymbol } = require('internal/dgram'); @@ -513,14 +513,21 @@ class Control extends EventEmitter { } } +const channelDeprecationMsg = '_channel is deprecated. ' + + 'Use ChildProcess.channel instead.'; + function setupChannel(target, channel) { target.channel = channel; - // _channel can be deprecated in version 8 Object.defineProperty(target, '_channel', { - get() { return target.channel; }, - set(val) { target.channel = val; }, - enumerable: true + get: deprecate(() => { + return target.channel; + }, channelDeprecationMsg, 'DEP0129'), + set: deprecate((val) => { + target.channel = val; + }, channelDeprecationMsg, 'DEP0129'), + configurable: true, + enumerable: false }); target._handleQueue = null;