diff --git a/src/asar_monkey_patch.js b/src/asar_monkey_patch.js index 1a06739..3d3a9ad 100644 --- a/src/asar_monkey_patch.js +++ b/src/asar_monkey_patch.js @@ -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) { diff --git a/src/yode.cc b/src/yode.cc index d482ceb..2f32490 100644 --- a/src/yode.cc +++ b/src/yode.cc @@ -65,10 +65,18 @@ void Bootstrap(node::Environment* env, // Invoke the |bootstrap| with |exports|. std::vector> 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.