@@ -101,10 +101,12 @@ void AsyncRequest::MemoryInfo(MemoryTracker* tracker) const {
101
101
Worker::Worker (Environment* env,
102
102
Local<Object> wrap,
103
103
const std::string& url,
104
- std::shared_ptr<PerIsolateOptions> per_isolate_opts)
104
+ std::shared_ptr<PerIsolateOptions> per_isolate_opts,
105
+ std::vector<std::string>&& exec_argv)
105
106
: AsyncWrap(env, wrap, AsyncWrap::PROVIDER_WORKER),
106
107
url_ (url),
107
108
per_isolate_opts_(per_isolate_opts),
109
+ exec_argv_(exec_argv),
108
110
platform_(env->isolate_data ()->platform()),
109
111
profiler_idle_notifier_started_(env->profiler_idle_notifier_started ()),
110
112
thread_id_(Environment::AllocateThreadId()) {
@@ -284,7 +286,7 @@ void Worker::Run() {
284
286
285
287
env_->Start (profiler_idle_notifier_started_);
286
288
env_->ProcessCliArgs (std::vector<std::string>{},
287
- std::vector<std::string>{} );
289
+ std::move (exec_argv_) );
288
290
}
289
291
290
292
Debug (this , " Created Environment for worker with id %llu" , thread_id_);
@@ -434,6 +436,9 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
434
436
std::string url;
435
437
std::shared_ptr<PerIsolateOptions> per_isolate_opts = nullptr ;
436
438
439
+ std::vector<std::string> exec_argv_out;
440
+ bool has_explicit_exec_argv = false ;
441
+
437
442
// Argument might be a string or URL
438
443
if (args.Length () > 0 && !args[0 ]->IsNullOrUndefined ()) {
439
444
Utf8Value value (
@@ -445,6 +450,7 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
445
450
v8::Local<v8::Array> array = args[1 ].As <v8::Array>();
446
451
// The first argument is reserved for program name, but we don't need it
447
452
// in workers.
453
+ has_explicit_exec_argv = true ;
448
454
std::vector<std::string> exec_argv = {" " };
449
455
uint32_t length = array->Length ();
450
456
for (uint32_t i = 0 ; i < length; i++) {
@@ -472,7 +478,7 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
472
478
// options for the per isolate parser.
473
479
options_parser::PerIsolateOptionsParser::instance.Parse (
474
480
&exec_argv,
475
- nullptr ,
481
+ &exec_argv_out ,
476
482
&invalid_args,
477
483
per_isolate_opts.get (),
478
484
kDisallowedInEnvironment ,
@@ -492,7 +498,9 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
492
498
}
493
499
}
494
500
}
495
- new Worker (env, args.This (), url, per_isolate_opts);
501
+ if (!has_explicit_exec_argv)
502
+ exec_argv_out = env->exec_argv ();
503
+ new Worker (env, args.This (), url, per_isolate_opts, std::move (exec_argv_out));
496
504
}
497
505
498
506
void Worker::StartThread (const FunctionCallbackInfo<Value>& args) {
0 commit comments