worker_threads
not respecting --require
in process.execArgv
or process.env.NODE_OPTIONS
#37410
Labels
worker
Issues and PRs related to Worker support.
Linux 3.10.0-1127.8.2.el7.x86_64 #1 SMP Tue May 12 16:57:42 UTC 2020 x86_64 GNU/Linux
)Microsoft Windows NT 10.0.19041.0 x64
)What steps will reproduce the bug?
Mutate either
process.env.NODE_OPTIONS
orprocess.execArgv
to include a--require
flag before spawning a worker thread.Test script
What is the expected behavior?
The
--require
flag is respected in each case:What do you see instead?
The
--require
flag is not respected:Additional information
tl;dr: Seems like the default value of
env
andexecArgv
options of theWorker
constructor is the initial value ofprocess.env
andprocess.execArgv
instead of the current value. This behavior is in contrast tochild_process.fork
.Full test script
This is the full test script with all the tests I have done (detailed below).
Test script
Expected output
Actual output
Running
node
with--require
affects worker threadsModify the test script to use the following test case
Then run the script with
node --require ./main.js main.js
outputs:which shows the
--require
flag is respected in both the main thread and the worker thread--require
inWorker
options is respectedWhen explicitly passing
execArgv
orenv.NODE_OPTIONS
to theWorker
constructor options, the--require
flag is respected:The above logs:
child_process.fork
respects--require
inprocess.execArgv
orprocess.env.NODE_OPTIONS
The above logs:
The text was updated successfully, but these errors were encountered: