Skip to content

Commit

Permalink
Print errors for bootstrap failure
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Jan 7, 2025
1 parent 8a7655b commit becaeb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/asar_monkey_patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ exports.wrapFsWithAsar = function(fs) {
return files
}

const {internalBinding} = require('internal/bootstrap/realm')
const modulesBinding = internalBinding('modules')
const {readPackageJSON} = modulesBinding
modulesBinding.readPackageJSON = function(p, isESM, base, specifier) {
Expand Down
16 changes: 12 additions & 4 deletions src/yode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ void Bootstrap(node::Environment* env,
// Invoke the |bootstrap| with |exports|.
std::vector<v8::Local<v8::Value>> args = { process, require, exports };
TryCatchScope try_catch(env, TryCatchScope::CatchMode::kFatal);
bootstrap->Call(env->context(),
env->context()->Global(),
args.size(),
args.data()).ToLocalChecked();
result = bootstrap->Call(env->context(),
env->context()->Global(),
args.size(),
args.data());
if (try_catch.HasCaught()) {
node::AppendExceptionLine(env,
try_catch.Exception(),
try_catch.Message(),
node::FATAL_ERROR);
} else {
result.ToLocalChecked();
}
}

// Like SpinEventLoop but replaces the uv_run with RunLoop.
Expand Down

0 comments on commit becaeb1

Please sign in to comment.