diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index 8de57a5666131f..c306de7db630f4 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -13,6 +13,7 @@ const { const { getOptionValue, getEmbedderOptions, + refreshOptions, } = require('internal/options'); const { reconnectZeroFillToggle } = require('internal/buffer'); const { @@ -26,6 +27,8 @@ const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes; const assert = require('internal/assert'); function prepareMainThreadExecution(expandArgv1 = false) { + refreshRuntimeOptions(); + // TODO(joyeecheung): this is also necessary for workers when they deserialize // this toggle from the snapshot. reconnectZeroFillToggle(); @@ -86,6 +89,10 @@ function prepareMainThreadExecution(expandArgv1 = false) { initializeFrozenIntrinsics(); } +function refreshRuntimeOptions() { + refreshOptions(); +} + function patchProcessObject(expandArgv1) { const binding = internalBinding('process_methods'); binding.patchProcessObject(process); @@ -541,6 +548,7 @@ function loadPreloadModules() { } module.exports = { + refreshRuntimeOptions, patchProcessObject, setupCoverageHooks, setupWarningHandler, diff --git a/lib/internal/options.js b/lib/internal/options.js index 01b334d4ec5614..4d92ad681a1207 100644 --- a/lib/internal/options.js +++ b/lib/internal/options.js @@ -36,6 +36,11 @@ function getEmbedderOptions() { return embedderOptions; } +function refreshOptions() { + optionsMap = undefined; + aliasesMap = undefined; +} + function getOptionValue(optionName) { const options = getCLIOptionsFromBinding(); if (optionName.startsWith('--no-')) { @@ -68,5 +73,6 @@ module.exports = { }, getOptionValue, getAllowUnauthorized, - getEmbedderOptions + getEmbedderOptions, + refreshOptions };