Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
joyeecheung committed Apr 19, 2018
commit 5e5a7b6d49b173178cb9705b64e035ba68cc5a42
3 changes: 2 additions & 1 deletion src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()) {
Expand Down
3 changes: 2 additions & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,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.
Expand All @@ -861,7 +863,6 @@ class ContextifyScript : public BaseObject {
} else if (received_signal) {
env->ThrowError("Script execution interrupted.");
}
env->isolate()->CancelTerminateExecution();
}

if (try_catch.HasCaught()) {
Expand Down