Skip to content

Commit

Permalink
worker: inherits mutated NODE_OPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis committed Sep 20, 2022
1 parent 5e3d003 commit 3571383
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class Worker extends EventEmitter {

// Set up the C++ handle for the worker, as well as some internal wiring.
this[kHandle] = new WorkerImpl(url,
env === process.env ? null : env,
env,
options.execArgv,
parseResourceLimits(options.resourceLimits),
!!(options.trackUnmanagedFds ?? true));
Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-worker-process-env-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
const { Worker } = require('node:worker_threads');

if (!require.main) {
globalThis.setup = true;
} else {
process.env.NODE_OPTIONS ??= ``;
process.env.NODE_OPTIONS += ` --require ${JSON.stringify(__filename)}`;

new Worker(`
const assert = require('assert');
assert.strictEqual(globalThis.setup, true);
`, { eval: true });
}

0 comments on commit 3571383

Please sign in to comment.