src: CancelTerminateExecution before throwing errors
Terminating the execution of a script would create a pending exception, therefore we should cancel the termination *before* throwing a new exception, otherwise the attempt to create a custom error may fail. PR-URL: https://github.com/nodejs/node/pull/20146 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
f31fc9398d
commit
3eeb346aa9
@ -279,7 +279,9 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
|
||||
result = module->Evaluate(context);
|
||||
}
|
||||
|
||||
// Convert the termination exception into a regular exception.
|
||||
if (timed_out || received_signal) {
|
||||
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
|
||||
// from this invocation is responsible for termination.
|
||||
@ -288,7 +290,6 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
|
||||
} else if (received_signal) {
|
||||
env->ThrowError("Script execution interrupted.");
|
||||
}
|
||||
env->isolate()->CancelTerminateExecution();
|
||||
}
|
||||
|
||||
if (try_catch.HasCaught()) {
|
||||
|
@ -851,7 +851,9 @@ class ContextifyScript : public BaseObject {
|
||||
result = script->Run(env->context());
|
||||
}
|
||||
|
||||
// Convert the termination exception into a regular exception.
|
||||
if (timed_out || received_signal) {
|
||||
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
|
||||
// from this invocation is responsible for termination.
|
||||
@ -860,7 +862,6 @@ class ContextifyScript : public BaseObject {
|
||||
} else if (received_signal) {
|
||||
env->ThrowError("Script execution interrupted.");
|
||||
}
|
||||
env->isolate()->CancelTerminateExecution();
|
||||
}
|
||||
|
||||
if (try_catch.HasCaught()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user