fix: bad js-flags shouldn't crash the app (#42440)

* fix: bad js-flags shouldn't crash the app

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update shell/browser/javascript_environment.cc

Co-authored-by: Robo <hop2deep@gmail.com>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2024-06-11 12:53:15 -05:00 committed by GitHub
parent 21085db4e3
commit b21d7884e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -281,13 +281,10 @@ class TracingControllerImpl : public node::tracing::TracingController {
v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop, v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop,
bool setup_wasm_streaming) { bool setup_wasm_streaming) {
auto* cmd = base::CommandLine::ForCurrentProcess(); auto* cmd = base::CommandLine::ForCurrentProcess();
// --js-flags. // --js-flags.
std::string js_flags = std::string js_flags = "--no-freeze-flags-after-init ";
cmd->GetSwitchValueASCII(blink::switches::kJavaScriptFlags); js_flags.append(cmd->GetSwitchValueASCII(blink::switches::kJavaScriptFlags));
js_flags.append(" --no-freeze-flags-after-init"); v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
if (!js_flags.empty())
v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
// The V8Platform of gin relies on Chromium's task schedule, which has not // The V8Platform of gin relies on Chromium's task schedule, which has not
// been started at this point, so we have to rely on Node's V8Platform. // been started at this point, so we have to rely on Node's V8Platform.