-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
// Flags: --expose-internals | ||
// Flags: --expose-internals --expose-gc | ||
'use strict'; | ||
require('../common'); | ||
const { Worker } = require('worker_threads'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const CODE = ` | ||
// If the --expose-internals flag does not pass to worker | ||
// require function will throw an error | ||
require('internal/options'); | ||
`; | ||
// Test if the flags is passed to worker threads | ||
// Test if the flags is passed to worker threads collectly | ||
// and do not throw an error with the invalid execArgv | ||
// when execArgv is inherited from parent | ||
// See https://github.com/nodejs/node/issues/52825 | ||
// See https://github.com/nodejs/node/issues/53011 | ||
// Inherited env, execArgv from the parent will be ok | ||
new Worker(CODE, { eval: true }); | ||
new Worker(CODE, { eval: true, env: process.env, execArgv: ['--expose-internals'] }); | ||
// Pass process.env explicitly and inherited execArgv(Node.js options) from parent will be ok | ||
new Worker(CODE, { eval: true, env: process.env }); | ||
// Inherited env from the parent and pass execArgv(Node.js options) explicitly will be ok | ||
new Worker(CODE, { eval: true, execArgv: ['--expose-internals'] }); | ||
// Pass process.env and execArgv(Node.js options) explicitly will be ok | ||
new Worker(CODE, { eval: true, env: process.env, execArgv: ['--expose-internals'] }); | ||
// Pass execArgv(V8 options) explicitly will throw an error | ||
assert.throws(() => { | ||
new Worker(CODE, { eval: true, execArgv: ['--expose-gc'] }) | ||
Check failure on line 28 in test/parallel/test-worker-cli-options.js GitHub Actions / lint-js-and-md
|
||
}, /ERR_WORKER_INVALID_EXEC_ARGV/); |