Skip to content

Commit 98281b1

Browse files
committed
src: add flags for controlling process behavior
nodejs/node#40339
1 parent d8b84d3 commit 98281b1

File tree

4 files changed

+13
-162
lines changed

4 files changed

+13
-162
lines changed

patches/node/.patches

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ feat_initialize_asar_support.patch
44
expose_get_builtin_module_function.patch
55
build_add_gn_build_files.patch
66
fix_add_default_values_for_variables_in_common_gypi.patch
7-
feat_add_flags_for_low-level_hooks_and_exceptions.patch
87
fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch
98
pass_all_globals_through_require.patch
109
build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch
@@ -19,7 +18,6 @@ fix_allow_preventing_initializeinspector_in_env.patch
1918
src_allow_embedders_to_provide_a_custom_pageallocator_to.patch
2019
fix_crypto_tests_to_run_with_bssl.patch
2120
fix_account_for_debugger_agent_race_condition.patch
22-
add_should_read_node_options_from_env_option_to_disable_node_options.patch
2321
repl_fix_crash_when_sharedarraybuffer_disabled.patch
2422
fix_readbarrier_undefined_symbol_error_on_woa_arm64.patch
2523
chore_fix_-wimplicit-fallthrough.patch

patches/node/add_should_read_node_options_from_env_option_to_disable_node_options.patch

Lines changed: 0 additions & 68 deletions
This file was deleted.

patches/node/feat_add_flags_for_low-level_hooks_and_exceptions.patch

Lines changed: 0 additions & 81 deletions
This file was deleted.

shell/common/node_bindings.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ bool NodeBindings::IsInitialized() {
365365
void NodeBindings::Initialize() {
366366
TRACE_EVENT0("electron", "NodeBindings::Initialize");
367367
// Open node's error reporting system for browser process.
368-
node::g_upstream_node_mode = false;
369368

370369
#if BUILDFLAG(IS_LINUX)
371370
// Get real command line in renderer process forked by zygote.
@@ -381,14 +380,17 @@ void NodeBindings::Initialize() {
381380

382381
auto env = base::Environment::Create();
383382
SetNodeOptions(env.get());
384-
node::Environment::should_read_node_options_from_env_ =
385-
fuses::IsNodeOptionsEnabled();
386383

387384
std::vector<std::string> argv = {"electron"};
388385
std::vector<std::string> exec_argv;
389386
std::vector<std::string> errors;
387+
uint64_t process_flags = node::ProcessFlags::kEnableStdioInheritance;
388+
if (!fuses::IsNodeOptionsEnabled())
389+
process_flags |= node::ProcessFlags::kDisableNodeOptionsEnv;
390390

391-
int exit_code = node::InitializeNodeWithArgs(&argv, &exec_argv, &errors);
391+
int exit_code = node::InitializeNodeWithArgs(
392+
&argv, &exec_argv, &errors,
393+
static_cast<node::ProcessFlags::Flags>(process_flags));
392394

393395
for (const std::string& error : errors)
394396
fprintf(stderr, "%s: %s\n", argv[0].c_str(), error.c_str());
@@ -466,20 +468,20 @@ node::Environment* NodeBindings::CreateEnvironment(
466468
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform);
467469

468470
node::Environment* env;
469-
uint64_t flags = node::EnvironmentFlags::kDefaultFlags |
470-
node::EnvironmentFlags::kHideConsoleWindows |
471-
node::EnvironmentFlags::kNoGlobalSearchPaths;
471+
uint64_t env_flags = node::EnvironmentFlags::kDefaultFlags |
472+
node::EnvironmentFlags::kHideConsoleWindows |
473+
node::EnvironmentFlags::kNoGlobalSearchPaths;
472474

473475
if (browser_env_ != BrowserEnvironment::kBrowser) {
474476
// Only one ESM loader can be registered per isolate -
475477
// in renderer processes this should be blink. We need to tell Node.js
476478
// not to register its handler (overriding blinks) in non-browser processes.
477-
flags |= node::EnvironmentFlags::kNoRegisterESMLoader |
478-
node::EnvironmentFlags::kNoInitializeInspector;
479+
env_flags |= node::EnvironmentFlags::kNoRegisterESMLoader |
480+
node::EnvironmentFlags::kNoInitializeInspector;
479481
v8::TryCatch try_catch(context->GetIsolate());
480482
env = node::CreateEnvironment(
481483
isolate_data_, context, args, exec_args,
482-
static_cast<node::EnvironmentFlags::Flags>(flags));
484+
static_cast<node::EnvironmentFlags::Flags>(env_flags));
483485
DCHECK(env);
484486

485487
// This will only be caught when something has gone terrible wrong as all
@@ -491,7 +493,7 @@ node::Environment* NodeBindings::CreateEnvironment(
491493
} else {
492494
env = node::CreateEnvironment(
493495
isolate_data_, context, args, exec_args,
494-
static_cast<node::EnvironmentFlags::Flags>(flags));
496+
static_cast<node::EnvironmentFlags::Flags>(env_flags));
495497
DCHECK(env);
496498
}
497499

0 commit comments

Comments
 (0)