chore: bump Node.js to v16.2.0 (#29244)
This commit is contained in:
parent
9a7e61cfc0
commit
542abcd6fd
51 changed files with 1829 additions and 1499 deletions
|
@ -49,7 +49,7 @@ namespace {
|
|||
|
||||
// Initialize Node.js cli options to pass to Node.js
|
||||
// See https://nodejs.org/api/cli.html#cli_options
|
||||
void SetNodeCliFlags() {
|
||||
int SetNodeCliFlags() {
|
||||
// Options that are unilaterally disallowed
|
||||
const std::unordered_set<base::StringPiece, base::StringPieceHash>
|
||||
disallowed = {"--openssl-config", "--use-bundled-ca", "--use-openssl-ca",
|
||||
|
@ -74,6 +74,10 @@ void SetNodeCliFlags() {
|
|||
if (disallowed.count(stripped) != 0) {
|
||||
LOG(ERROR) << "The Node.js cli flag " << stripped
|
||||
<< " is not supported in Electron";
|
||||
// Node.js returns 9 from ProcessGlobalArgs for any errors encountered
|
||||
// when setting up cli flags and env vars. Since we're outlawing these
|
||||
// flags (making them errors) return 9 here for consistency.
|
||||
return 9;
|
||||
} else {
|
||||
args.push_back(option);
|
||||
}
|
||||
|
@ -83,7 +87,8 @@ void SetNodeCliFlags() {
|
|||
|
||||
// Node.js itself will output parsing errors to
|
||||
// console so we don't need to handle that ourselves
|
||||
ProcessGlobalArgs(&args, nullptr, &errors, node::kDisallowedInEnvironment);
|
||||
return ProcessGlobalArgs(&args, nullptr, &errors,
|
||||
node::kDisallowedInEnvironment);
|
||||
}
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
|
@ -156,7 +161,6 @@ int NodeMain(int argc, char* argv[]) {
|
|||
int exit_code = 1;
|
||||
{
|
||||
// Feed gin::PerIsolateData with a task runner.
|
||||
argv = uv_setup_args(argc, argv);
|
||||
uv_loop_t* loop = uv_default_loop();
|
||||
auto uv_task_runner = base::MakeRefCounted<UvTaskRunner>(loop);
|
||||
base::ThreadTaskRunnerHandle handle(uv_task_runner);
|
||||
|
@ -170,11 +174,15 @@ int NodeMain(int argc, char* argv[]) {
|
|||
NodeBindings::RegisterBuiltinModules();
|
||||
|
||||
// Parse and set Node.js cli flags.
|
||||
SetNodeCliFlags();
|
||||
int flags_exit_code = SetNodeCliFlags();
|
||||
if (flags_exit_code != 0)
|
||||
exit(flags_exit_code);
|
||||
|
||||
int exec_argc;
|
||||
const char** exec_argv;
|
||||
node::Init(&argc, const_cast<const char**>(argv), &exec_argc, &exec_argv);
|
||||
node::InitializationResult result =
|
||||
node::InitializeOncePerProcess(argc, argv);
|
||||
|
||||
if (result.early_return)
|
||||
exit(result.exit_code);
|
||||
|
||||
gin::V8Initializer::LoadV8Snapshot(
|
||||
gin::V8Initializer::V8SnapshotFileType::kWithAdditionalContext);
|
||||
|
@ -201,11 +209,8 @@ int NodeMain(int argc, char* argv[]) {
|
|||
isolate_data = node::CreateIsolateData(isolate, loop, gin_env.platform());
|
||||
CHECK_NE(nullptr, isolate_data);
|
||||
|
||||
std::vector<std::string> args(argv, argv + argc); // NOLINT
|
||||
std::vector<std::string> exec_args(exec_argv,
|
||||
exec_argv + exec_argc); // NOLINT
|
||||
env = node::CreateEnvironment(isolate_data, gin_env.context(), args,
|
||||
exec_args);
|
||||
env = node::CreateEnvironment(isolate_data, gin_env.context(),
|
||||
result.args, result.exec_args);
|
||||
CHECK_NOT_NULL(env);
|
||||
|
||||
node::IsolateSettings is;
|
||||
|
@ -240,7 +245,7 @@ int NodeMain(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
v8::HandleScope scope(isolate);
|
||||
node::LoadEnvironment(env);
|
||||
node::LoadEnvironment(env, node::StartExecutionCallback{});
|
||||
|
||||
env->set_trace_sync_io(env->options()->trace_sync_io);
|
||||
|
||||
|
|
|
@ -247,6 +247,9 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
|
|||
|
||||
env->set_trace_sync_io(env->options()->trace_sync_io);
|
||||
|
||||
// We do not want to crash the main process on unhandled rejections.
|
||||
env->set_unhandled_rejections_mode("warn");
|
||||
|
||||
// Add Electron extended APIs.
|
||||
electron_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
|
||||
|
|
|
@ -168,7 +168,6 @@ JavascriptEnvironment::~JavascriptEnvironment() {
|
|||
isolate_->Exit();
|
||||
g_isolate = nullptr;
|
||||
|
||||
platform_->CancelPendingDelayedTasks(isolate_);
|
||||
platform_->UnregisterIsolate(isolate_);
|
||||
}
|
||||
|
||||
|
|
|
@ -362,13 +362,11 @@ void NodeBindings::Initialize() {
|
|||
|
||||
int exit_code = node::InitializeNodeWithArgs(&argv, &exec_argv, &errors);
|
||||
|
||||
for (const std::string& error : errors) {
|
||||
for (const std::string& error : errors)
|
||||
fprintf(stderr, "%s: %s\n", argv[0].c_str(), error.c_str());
|
||||
}
|
||||
|
||||
if (exit_code != 0) {
|
||||
if (exit_code != 0)
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// uv_init overrides error mode to suppress the default crash dialog, bring
|
||||
|
@ -518,7 +516,7 @@ node::Environment* NodeBindings::CreateEnvironment(
|
|||
}
|
||||
|
||||
void NodeBindings::LoadEnvironment(node::Environment* env) {
|
||||
node::LoadEnvironment(env);
|
||||
node::LoadEnvironment(env, node::StartExecutionCallback{});
|
||||
gin_helper::EmitEvent(env->isolate(), env->process_object(), "loaded");
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,9 @@ void ElectronRendererClient::DidCreateScriptContext(
|
|||
// any non-context aware native module
|
||||
env->set_force_context_aware(true);
|
||||
|
||||
// We do not want to crash the renderer process on unhandled rejections.
|
||||
env->set_unhandled_rejections_mode("warn");
|
||||
|
||||
environments_.insert(env);
|
||||
|
||||
// Add Electron extended APIs.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue