File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ // Tests that NODE_OPTIONS set at runtime in the parent process
4+ // are picked up by a worker thread even when the env option is
5+ // not explicitly provided to the Worker constructor.
6+ const { Worker, isMainThread } = require ( 'worker_threads' ) ;
7+
8+ if ( isMainThread ) {
9+ process . env . NODE_OPTIONS = '--trace-exit' ;
10+ new Worker ( __filename ) ;
11+ } else {
12+ setImmediate ( ( ) => {
13+ process . nextTick ( ( ) => {
14+ process . exit ( 0 ) ;
15+ } ) ;
16+ } ) ;
17+ }
Original file line number Diff line number Diff line change @@ -38,3 +38,20 @@ spawnSyncAndAssert(
3838 stderr : / s p a w n - w o r k e r - w i t h - t r a c e - e x i t \. j s : 1 7 /
3939 }
4040) ;
41+
42+ // Test that NODE_OPTIONS set at runtime in the parent process are
43+ // picked up by a worker even when the env option is not provided.
44+ spawnSyncAndAssert (
45+ process . execPath ,
46+ [
47+ fixtures . path ( 'spawn-worker-without-env-option' ) ,
48+ ] ,
49+ {
50+ env : {
51+ ...process . env ,
52+ }
53+ } ,
54+ {
55+ stderr : / s p a w n - w o r k e r - w i t h o u t - e n v - o p t i o n \. j s : 1 4 /
56+ }
57+ ) ;
You can’t perform that action at this time.
0 commit comments