summaryrefslogtreecommitdiff
path: root/test/parallel/test-inspect-support-for-node_options.js
diff options
context:
space:
mode:
authorSameer Srivastava <sameer13@gmail.com>2018-03-06 14:27:49 +0530
committerRichard Lau <riclau@uk.ibm.com>2018-03-21 15:27:54 -0400
commit9b34ea6161a637d6be7a68b816df8f8479d7c4ee (patch)
tree8d72900a0022253fcf5cd13f6d946555621cc034 /test/parallel/test-inspect-support-for-node_options.js
parent6a9f0499688b7515f3156a1754583d7624b25989 (diff)
downloadnode-new-9b34ea6161a637d6be7a68b816df8f8479d7c4ee.tar.gz
cluster: add support for NODE_OPTIONS="--inspect"
When using cluster and --inspect as cli argument it is correctly handled and each worker will use a different port, this was fixed by #13619. But when env var NODE_OPTIONS="--inspect" is set this logic doesn't apply and the workers will fail as they try to attach to the same port. Fixes: https://github.com/nodejs/node/issues/19026 PR-URL: https://github.com/nodejs/node/pull/19165 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'test/parallel/test-inspect-support-for-node_options.js')
-rw-r--r--test/parallel/test-inspect-support-for-node_options.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/parallel/test-inspect-support-for-node_options.js b/test/parallel/test-inspect-support-for-node_options.js
new file mode 100644
index 0000000000..05c7ec24b9
--- /dev/null
+++ b/test/parallel/test-inspect-support-for-node_options.js
@@ -0,0 +1,30 @@
+'use strict';
+const common = require('../common');
+const cluster = require('cluster');
+const assert = require('assert');
+
+common.skipIfInspectorDisabled();
+
+checkForInspectSupport('--inspect');
+
+function checkForInspectSupport(flag) {
+
+ const nodeOptions = JSON.stringify(flag);
+ const numWorkers = 2;
+ process.env.NODE_OPTIONS = flag;
+
+ if (cluster.isMaster) {
+ for (let i = 0; i < numWorkers; i++) {
+ cluster.fork();
+ }
+
+ cluster.on('online', (worker) => {
+ worker.disconnect();
+ });
+
+ cluster.on('exit', common.mustCall((worker, code, signal) => {
+ const errMsg = `For NODE_OPTIONS ${nodeOptions}, failed to start cluster`;
+ assert.strictEqual(worker.exitedAfterDisconnect, true, errMsg);
+ }, numWorkers));
+ }
+}