Skip to content

Commit

Permalink
src: do not crash if ToggleAsyncHook fails during termination
Browse files Browse the repository at this point in the history
In the termination case, we should not crash. There’s also no harm
being done by ignoring the termination exception here, since the
thread is about to be torn down anyway.

Also, add a guard against running this during shutdown. That is the
likely cause of nodejs#34361.

Fixes: nodejs#34361
  • Loading branch information
addaleax committed Jul 14, 2020
1 parent 4195c31 commit 643a109
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,14 @@ void Agent::DisableAsyncHook() {

void Agent::ToggleAsyncHook(Isolate* isolate,
const Global<Function>& fn) {
if (!parent_env_->can_call_into_js()) return;
CHECK(parent_env_->has_run_bootstrapping_code());
HandleScope handle_scope(isolate);
CHECK(!fn.IsEmpty());
auto context = parent_env_->context();
v8::TryCatch try_catch(isolate);
USE(fn.Get(isolate)->Call(context, Undefined(isolate), 0, nullptr));
if (try_catch.HasCaught()) {
if (try_catch.HasCaught() && !try_catch.HasTerminated()) {
PrintCaughtException(isolate, context, try_catch);
FatalError("\nnode::inspector::Agent::ToggleAsyncHook",
"Cannot toggle Inspector's AsyncHook, please report this.");
Expand Down

0 comments on commit 643a109

Please sign in to comment.