|
1 | | -// Flags: --expose-internals |
| 1 | +// Flags: --expose-internals --expose-gc |
2 | 2 | 'use strict'; |
3 | 3 | require('../common'); |
4 | 4 | const { Worker } = require('worker_threads'); |
| 5 | +const assert = require('assert'); |
5 | 6 |
|
6 | 7 | const CODE = ` |
7 | 8 | // If the --expose-internals flag does not pass to worker |
8 | 9 | // require function will throw an error |
9 | 10 | require('internal/options'); |
| 11 | +global.gc(); |
10 | 12 | `; |
11 | | -// Test if the flags is passed to worker threads |
| 13 | + |
| 14 | +// Test if the flags is passed to worker threads correctly |
| 15 | +// and do not throw an error with the invalid execArgv |
| 16 | +// when execArgv is inherited from parent |
12 | 17 | // See https://github.com/nodejs/node/issues/52825 |
| 18 | +// See https://github.com/nodejs/node/issues/53011 |
| 19 | + |
| 20 | +// Inherited env, execArgv from the parent will be ok |
13 | 21 | new Worker(CODE, { eval: true }); |
14 | | -new Worker(CODE, { eval: true, env: process.env, execArgv: ['--expose-internals'] }); |
| 22 | +// Pass process.env explicitly and inherited execArgv from parent will be ok |
15 | 23 | new Worker(CODE, { eval: true, env: process.env }); |
| 24 | +// Inherited env from the parent and pass execArgv (Node.js options) explicitly will be ok |
16 | 25 | new Worker(CODE, { eval: true, execArgv: ['--expose-internals'] }); |
| 26 | +// Pass process.env and execArgv (Node.js options) explicitly will be ok |
| 27 | +new Worker(CODE, { eval: true, env: process.env, execArgv: ['--expose-internals'] }); |
| 28 | +// Pass execArgv (V8 options) explicitly will throw an error |
| 29 | +assert.throws(() => { |
| 30 | + new Worker(CODE, { eval: true, execArgv: ['--expose-gc'] }); |
| 31 | +}, /ERR_WORKER_INVALID_EXEC_ARGV/); |
0 commit comments