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