diff options
Diffstat (limited to 'lib/internal/bootstrap/node.js')
-rw-r--r-- | lib/internal/bootstrap/node.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 86c0cf7aaf..789d8c1754 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -181,7 +181,7 @@ function startup() { // TODO(joyeecheung): move this down further to get better snapshotting const experimentalPolicy = getOptionValue('--experimental-policy'); - if (experimentalPolicy) { + if (isMainThread && experimentalPolicy) { process.emitWarning('Policies are experimental.', 'ExperimentalWarning'); const { pathToFileURL, URL } = NativeModule.require('url'); @@ -348,8 +348,6 @@ function startup() { } function startWorkerThreadExecution() { - prepareUserCodeExecution(); - // If we are in a worker thread, execute the script sent through the // message port. const { @@ -366,7 +364,9 @@ function startWorkerThreadExecution() { debug(`[${threadId}] is setting up worker child environment`); const port = getEnvMessagePort(); - port.on('message', createMessageHandler(port)); + port.on('message', createMessageHandler( + port, + prepareUserCodeExecution)); port.start(); // Overwrite fatalException @@ -460,7 +460,7 @@ function prepareUserCodeExecution() { // For user code, we preload modules if `-r` is passed const preloadModules = getOptionValue('--require'); - if (preloadModules) { + if (preloadModules.length) { const { _preloadModules } = NativeModule.require('internal/modules/cjs/loader'); |