Skip to content

Commit

Permalink
fix: exit early when SetNodeCliFlags() fails
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jun 7, 2021
1 parent ad460b2 commit 49d3b09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions script/node-disabled-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
"parallel/test-tls-client-mindhsize",
"parallel/test-tls-client-reject",
"parallel/test-tls-client-renegotiation-13",
"parallel/test-tls-client-resume",
"parallel/test-tls-client-resume-12",
"parallel/test-tls-cnnic-whitelist",
"parallel/test-tls-disable-renegotiation",
"parallel/test-tls-empty-sni-context",
"parallel/test-tls-env-bad-extra-ca",
Expand Down
10 changes: 7 additions & 3 deletions shell/app/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -74,6 +74,7 @@ void SetNodeCliFlags() {
if (disallowed.count(stripped) != 0) {
LOG(ERROR) << "The Node.js cli flag " << stripped
<< " is not supported in Electron";
return 9;
} else {
args.push_back(option);
}
Expand All @@ -83,7 +84,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)
Expand Down Expand Up @@ -169,7 +171,9 @@ 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);

node::InitializationResult result =
node::InitializeOncePerProcess(argc, argv);
Expand Down

0 comments on commit 49d3b09

Please sign in to comment.