@@ -40,7 +40,6 @@ using node::FatalError;
40
40
41
41
using v8::Context;
42
42
using v8::Function;
43
- using v8::Global;
44
43
using v8::HandleScope;
45
44
using v8::Isolate;
46
45
using v8::Local;
@@ -804,8 +803,8 @@ void Agent::PauseOnNextJavascriptStatement(const std::string& reason) {
804
803
void Agent::RegisterAsyncHook (Isolate* isolate,
805
804
Local<Function> enable_function,
806
805
Local<Function> disable_function) {
807
- enable_async_hook_function_. Reset (isolate, enable_function);
808
- disable_async_hook_function_. Reset (isolate, disable_function);
806
+ parent_env_-> set_inspector_enable_async_hooks ( enable_function);
807
+ parent_env_-> set_inspector_disable_async_hooks ( disable_function);
809
808
if (pending_enable_async_hook_) {
810
809
CHECK (!pending_disable_async_hook_);
811
810
pending_enable_async_hook_ = false ;
@@ -818,8 +817,10 @@ void Agent::RegisterAsyncHook(Isolate* isolate,
818
817
}
819
818
820
819
void Agent::EnableAsyncHook () {
821
- if (!enable_async_hook_function_.IsEmpty ()) {
822
- ToggleAsyncHook (parent_env_->isolate (), enable_async_hook_function_);
820
+ HandleScope scope (parent_env_->isolate ());
821
+ Local<Function> enable = parent_env_->inspector_enable_async_hooks ();
822
+ if (!enable.IsEmpty ()) {
823
+ ToggleAsyncHook (parent_env_->isolate (), enable);
823
824
} else if (pending_disable_async_hook_) {
824
825
CHECK (!pending_enable_async_hook_);
825
826
pending_disable_async_hook_ = false ;
@@ -829,8 +830,10 @@ void Agent::EnableAsyncHook() {
829
830
}
830
831
831
832
void Agent::DisableAsyncHook () {
832
- if (!disable_async_hook_function_.IsEmpty ()) {
833
- ToggleAsyncHook (parent_env_->isolate (), disable_async_hook_function_);
833
+ HandleScope scope (parent_env_->isolate ());
834
+ Local<Function> disable = parent_env_->inspector_enable_async_hooks ();
835
+ if (!disable.IsEmpty ()) {
836
+ ToggleAsyncHook (parent_env_->isolate (), disable);
834
837
} else if (pending_enable_async_hook_) {
835
838
CHECK (!pending_disable_async_hook_);
836
839
pending_enable_async_hook_ = false ;
@@ -839,8 +842,7 @@ void Agent::DisableAsyncHook() {
839
842
}
840
843
}
841
844
842
- void Agent::ToggleAsyncHook (Isolate* isolate,
843
- const Global<Function>& fn) {
845
+ void Agent::ToggleAsyncHook (Isolate* isolate, Local<Function> fn) {
844
846
// Guard against running this during cleanup -- no async events will be
845
847
// emitted anyway at that point anymore, and calling into JS is not possible.
846
848
// This should probably not be something we're attempting in the first place,
@@ -851,7 +853,7 @@ void Agent::ToggleAsyncHook(Isolate* isolate,
851
853
CHECK (!fn.IsEmpty ());
852
854
auto context = parent_env_->context ();
853
855
v8::TryCatch try_catch (isolate);
854
- USE (fn. Get (isolate) ->Call (context, Undefined (isolate), 0 , nullptr ));
856
+ USE (fn->Call (context, Undefined (isolate), 0 , nullptr ));
855
857
if (try_catch.HasCaught () && !try_catch.HasTerminated ()) {
856
858
PrintCaughtException (isolate, context, try_catch);
857
859
FatalError (" \n node::inspector::Agent::ToggleAsyncHook" ,
0 commit comments