diff --git a/src/node.cc b/src/node.cc index 9f4323119e4c21..ec29ef5988f30c 100644 --- a/src/node.cc +++ b/src/node.cc @@ -910,6 +910,11 @@ int InitializeNodeWithArgs(std::vector* argv, // used in diagnostic reports. per_process::cli_options->cmdline = *argv; + // Node provides a "v8.setFlagsFromString" method to dynamically change flags. + // Hence do not freeze flags when initializing V8. In a browser setting, this + // is security relevant, for Node it's less important. + V8::SetFlagsFromString("--no-freeze-flags-after-init"); + #if defined(NODE_V8_OPTIONS) // Should come before the call to V8::SetFlagsFromCommandLine() // so the user can disable a flag --foo at run-time by passing diff --git a/test/cctest/node_test_fixture.cc b/test/cctest/node_test_fixture.cc index 8179c7864436b1..f0e5b48d4a84e1 100644 --- a/test/cctest/node_test_fixture.cc +++ b/test/cctest/node_test_fixture.cc @@ -24,6 +24,11 @@ void NodeTestEnvironment::SetUp() { #endif cppgc::InitializeProcess( NodeZeroIsolateTestFixture::platform->GetPageAllocator()); + + // Before initializing V8, disable the --freeze-flags-after-init flag, so + // individual tests can set their own flags. + v8::V8::SetFlagsFromString("--no-freeze-flags-after-init"); + v8::V8::Initialize(); } diff --git a/tools/code_cache/mkcodecache.cc b/tools/code_cache/mkcodecache.cc index 68690252a147cd..8d9b5e1b70397a 100644 --- a/tools/code_cache/mkcodecache.cc +++ b/tools/code_cache/mkcodecache.cc @@ -29,6 +29,8 @@ int main(int argc, char* argv[]) { v8::V8::SetFlagsFromString("--random_seed=42"); v8::V8::SetFlagsFromString("--harmony-import-assertions"); + // Do not freeze flags so we can later reset the random seed. + v8::V8::SetFlagsFromString("--no-freeze-flags-after-init"); if (argc < 2) { std::cerr << "Usage: " << argv[0] << " \n";