diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index f59df04672b703..c4fbacc0e0ae46 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -160,6 +160,9 @@ outside `node_modules` in order to better target developers, rather than users. ### DEP0006: child\_process options.customFds -Type: Runtime +Type: End-of-Life Within the [`child_process`][] module's `spawn()`, `fork()`, and `exec()` methods, the `options.customFds` option is deprecated. The `options.stdio` diff --git a/lib/child_process.js b/lib/child_process.js index 1a5411c8164c10..d70803866c1f58 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -22,9 +22,7 @@ 'use strict'; const util = require('util'); -const { - deprecate, convertToValidSignal, getSystemErrorName -} = require('internal/util'); +const { convertToValidSignal, getSystemErrorName } = require('internal/util'); const { isArrayBufferView } = require('internal/util/types'); const debug = util.debuglog('child_process'); const { Buffer } = require('buffer'); @@ -384,20 +382,6 @@ Object.defineProperty(exports.execFile, util.promisify.custom, { value: customPromiseExecFunction(exports.execFile) }); -const _deprecatedCustomFds = deprecate( - function deprecateCustomFds(options) { - options.stdio = options.customFds.map(function mapCustomFds(fd) { - return fd === -1 ? 'pipe' : fd; - }); - }, 'child_process: options.customFds option is deprecated. ' + - 'Use options.stdio instead.', 'DEP0006'); - -function _convertCustomFds(options) { - if (options.customFds && !options.stdio) { - _deprecatedCustomFds(options); - } -} - function normalizeSpawnArguments(file, args, options) { validateString(file, 'file'); @@ -526,8 +510,6 @@ function normalizeSpawnArguments(file, args, options) { } } - _convertCustomFds(options); - return { file: file, args: args, diff --git a/test/parallel/test-child-process-custom-fds.js b/test/parallel/test-child-process-custom-fds.js deleted file mode 100644 index 1c89c207d37f99..00000000000000 --- a/test/parallel/test-child-process-custom-fds.js +++ /dev/null @@ -1,47 +0,0 @@ -// Flags: --expose_internals -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const { spawnSync } = require('child_process'); -const internalCp = require('internal/child_process'); - -if (!common.isMainThread) - common.skip('stdio is not associated with file descriptors in Workers'); - -// This test uses the deprecated `customFds` option. We expect a deprecation -// warning, but only once (per node process). -const msg = 'child_process: options.customFds option is deprecated. ' + - 'Use options.stdio instead.'; -common.expectWarning('DeprecationWarning', msg, 'DEP0006'); - -// Verify that customFds is used if stdio is not provided. -{ - const customFds = [-1, process.stdout.fd, process.stderr.fd]; - const oldSpawnSync = internalCp.spawnSync; - internalCp.spawnSync = common.mustCall(function(opts) { - assert.deepStrictEqual(opts.options.customFds, customFds); - assert.deepStrictEqual(opts.options.stdio, [ - { type: 'pipe', readable: true, writable: false }, - { type: 'fd', fd: process.stdout.fd }, - { type: 'fd', fd: process.stderr.fd } - ]); - }); - spawnSync(...common.pwdCommand, { customFds }); - internalCp.spawnSync = oldSpawnSync; -} - -// Verify that customFds is ignored when stdio is present. -{ - const customFds = [0, 1, 2]; - const oldSpawnSync = internalCp.spawnSync; - internalCp.spawnSync = common.mustCall(function(opts) { - assert.deepStrictEqual(opts.options.customFds, customFds); - assert.deepStrictEqual(opts.options.stdio, [ - { type: 'pipe', readable: true, writable: false }, - { type: 'pipe', readable: false, writable: true }, - { type: 'pipe', readable: false, writable: true } - ]); - }); - spawnSync(...common.pwdCommand, { customFds, stdio: 'pipe' }); - internalCp.spawnSync = oldSpawnSync; -}