Skip to content

Commit

Permalink
src: make sure pass the cli_options to worker
Browse files Browse the repository at this point in the history
  • Loading branch information
theanarkh committed May 4, 2024
1 parent 4e9ce7c commit eda633c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
}

if (args[1]->IsObject() || args[2]->IsArray()) {
per_isolate_opts.reset(new PerIsolateOptions());
Mutex::ScopedLock lock(per_process::cli_options_mutex);
per_isolate_opts.reset(
new PerIsolateOptions(*per_process::cli_options->per_isolate));

HandleEnvOptions(per_isolate_opts->per_env, [&env_vars](const char* name) {
return env_vars->Get(name).FromMaybe("");
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-worker-cli-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Flags: --expose-internals
'use strict';
require('../common');
const { Worker, isMainThread } = require('worker_threads');

Check failure on line 4 in test/parallel/test-worker-cli-options.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'isMainThread' is assigned a value but never used

// Test if the flags is passed to worker threads
// See https://github.com/nodejs/node/issues/52825
new Worker(`
// If the --expose-internals flag does not pass to worker
// require function will throw an error
require('internal/options');
`, { eval: true, env: process.env });

0 comments on commit eda633c

Please sign in to comment.