diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-15 16:33:23 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-02-20 07:33:04 +0300 |
commit | 7b198935d63aec4acace1500d81ac2662c732d18 (patch) | |
tree | 48e461ef7a9b10381f89a491553903482197fb68 /src/module_wrap.cc | |
parent | d2c29bda50c4e5579537ab8cb9ac5d1f567da4a8 (diff) |
src: only call .ReThrow() if not terminating
Otherwise, it looks like a `null` exception is being thrown.
PR-URL: https://github.com/nodejs/node/pull/26130
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'src/module_wrap.cc')
-rw-r--r-- | src/module_wrap.cc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/module_wrap.cc b/src/module_wrap.cc index f642440bff5..93e791b5224 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -158,12 +158,13 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) { Context::Scope context_scope(context); ScriptCompiler::Source source(source_text, origin); if (!ScriptCompiler::CompileModule(isolate, &source).ToLocal(&module)) { - CHECK(try_catch.HasCaught()); - CHECK(!try_catch.Message().IsEmpty()); - CHECK(!try_catch.Exception().IsEmpty()); - AppendExceptionLine(env, try_catch.Exception(), try_catch.Message(), - ErrorHandlingMode::MODULE_ERROR); - try_catch.ReThrow(); + if (try_catch.HasCaught() && !try_catch.HasTerminated()) { + CHECK(!try_catch.Message().IsEmpty()); + CHECK(!try_catch.Exception().IsEmpty()); + AppendExceptionLine(env, try_catch.Exception(), try_catch.Message(), + ErrorHandlingMode::MODULE_ERROR); + try_catch.ReThrow(); + } return; } } @@ -245,13 +246,12 @@ void ModuleWrap::Instantiate(const FunctionCallbackInfo<Value>& args) { Local<Context> context = obj->context_.Get(isolate); Local<Module> module = obj->module_.Get(isolate); TryCatchScope try_catch(env); - Maybe<bool> ok = module->InstantiateModule(context, ResolveCallback); + USE(module->InstantiateModule(context, ResolveCallback)); // clear resolve cache on instantiate obj->resolve_cache_.clear(); - if (!ok.FromMaybe(false)) { - CHECK(try_catch.HasCaught()); + if (try_catch.HasCaught() && !try_catch.HasTerminated()) { CHECK(!try_catch.Message().IsEmpty()); CHECK(!try_catch.Exception().IsEmpty()); AppendExceptionLine(env, try_catch.Exception(), try_catch.Message(), @@ -300,6 +300,8 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) { // Convert the termination exception into a regular exception. if (timed_out || received_signal) { + if (!env->is_main_thread() && env->is_stopping_worker()) + return; env->isolate()->CancelTerminateExecution(); // It is possible that execution was terminated by another timeout in // which this timeout is nested, so check whether one of the watchdogs @@ -312,7 +314,8 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) { } if (try_catch.HasCaught()) { - try_catch.ReThrow(); + if (!try_catch.HasTerminated()) + try_catch.ReThrow(); return; } @@ -375,7 +378,6 @@ void ModuleWrap::GetError(const FunctionCallbackInfo<Value>& args) { ASSIGN_OR_RETURN_UNWRAP(&obj, args.This()); Local<Module> module = obj->module_.Get(isolate); - args.GetReturnValue().Set(module->GetException()); } |