diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 13ebffdc04935a..c1982f15a68c75 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -841,13 +841,14 @@ void Agent::DisableAsyncHook() { void Agent::ToggleAsyncHook(Isolate* isolate, const Global& 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.");