diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 47740c197a4928..1aef639cfc82e5 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2264,6 +2264,20 @@ undocumented `COUNTER_NET_SERVER_CONNECTION()`, `COUNTER_HTTP_SERVER_RESPONSE()`, `COUNTER_HTTP_CLIENT_REQUEST()`, and `COUNTER_HTTP_CLIENT_RESPONSE()` functions have been deprecated. + +### DEP00XX: net._setSimultaneousAccepts() + + +The undocumented `net._setSimultaneousAccepts()` function was originally +intended for debugging and performance tuning when using the `child_process` +and `cluster` modules on Windows. The function is not generally useful and +is being removed. See discussion here: +https://github.com/nodejs/node/issues/18391 [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 74d69de0dcdeee..a2478ec69de139 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -604,8 +604,7 @@ function setupChannel(target, channel) { // Update simultaneous accepts on Windows if (process.platform === 'win32') { - handle._simultaneousAccepts = false; - net._setSimultaneousAccepts(handle); + handle.setSimultaneousAccepts(false); } // Convert handle object @@ -700,8 +699,8 @@ function setupChannel(target, channel) { message = message.msg; // Update simultaneous accepts on Windows - if (obj.simultaneousAccepts) { - net._setSimultaneousAccepts(handle); + if (obj.simultaneousAccepts && process.platform === 'win32') { + handle.setSimultaneousAccepts(true); } } else if (this._handleQueue && !(message && (message.cmd === 'NODE_HANDLE_ACK' || diff --git a/lib/net.js b/lib/net.js index 33ce1f74eb2fba..d4b8bfcc2aeee7 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1668,11 +1668,18 @@ Server.prototype.unref = function() { }; var _setSimultaneousAccepts; +var warnSimultaneousAccepts = true; if (process.platform === 'win32') { var simultaneousAccepts; _setSimultaneousAccepts = function(handle) { + if (warnSimultaneousAccepts) { + process.emitWarning( + 'net._setSimultaneousAccepts() is deprecated and will be removed.', + 'DeprecationWarning', 'DEP00XX'); + warnSimultaneousAccepts = false; + } if (handle === undefined) { return; } @@ -1688,7 +1695,14 @@ if (process.platform === 'win32') { } }; } else { - _setSimultaneousAccepts = function() {}; + _setSimultaneousAccepts = function() { + if (warnSimultaneousAccepts) { + process.emitWarning( + 'net._setSimultaneousAccepts() is deprecated and will be removed.', + 'DeprecationWarning', 'DEP00XX'); + warnSimultaneousAccepts = false; + } + }; } module.exports = { diff --git a/test/parallel/test-net-deprecated-setsimultaneousaccepts.js b/test/parallel/test-net-deprecated-setsimultaneousaccepts.js new file mode 100644 index 00000000000000..6d1d62e6cb275f --- /dev/null +++ b/test/parallel/test-net-deprecated-setsimultaneousaccepts.js @@ -0,0 +1,16 @@ +// Flags: --no-warnings +'use strict'; + +const { + expectWarning +} = require('../common'); +const { + _setSimultaneousAccepts +} = require('net'); + +expectWarning( + 'DeprecationWarning', + 'net._setSimultaneousAccepts() is deprecated and will be removed.', + 'DEP00XX'); + +_setSimultaneousAccepts();