Skip to content

Commit

Permalink
support registering hook in worker threads
Browse files Browse the repository at this point in the history
  • Loading branch information
kherock committed May 31, 2022
1 parent d791afa commit 7335fed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ const { relay, send } = require('./ipc');
const resolveMain = require('./resolve-main');
const suppressExperimentalWarnings = require('./suppress-experimental-warnings');

// Experimental warnings need to be suppressed in worker threads as well, since
// their process inherits the Node arguments from the main thread.
suppressExperimentalWarnings(process);

// When using worker threads, each thread appears to require this file through
// the shared Node arguments (--require), so filter them out here and only run
// on the main thread.
if (!isMainThread) return;
if (isMainThread) {
// When using worker threads, each thread inherits execArgv and re-evaulates
// --require scripts. Worker threads do not inherit argv, so we copy argv[1]
// to the environment for those processes to use.
process.env.NODE_DEV_SCRIPT = process.argv[1];
}

const script = process.argv[1];
const script = process.env.NODE_DEV_SCRIPT;
const { extensions, fork, vm } = getConfig(script);

if (process.env.NODE_DEV_PRELOAD) {
Expand Down

0 comments on commit 7335fed

Please sign in to comment.