@@ -487,6 +487,8 @@ class NodeInspectorClient : public V8InspectorClient {
487487 }
488488
489489 if (interface_) {
490+ per_process::Debug (DebugCategory::INSPECTOR_CLIENT,
491+ " Stopping waiting for frontend events\n " );
490492 interface_->StopWaitingForFrontendEvent ();
491493 }
492494 }
@@ -668,11 +670,16 @@ class NodeInspectorClient : public V8InspectorClient {
668670
669671 running_nested_loop_ = true ;
670672
673+ per_process::Debug (DebugCategory::INSPECTOR_CLIENT,
674+ " Entering nested loop\n " );
675+
671676 while (shouldRunMessageLoop ()) {
672677 if (interface_) interface_->WaitForFrontendEvent ();
673678 env_->RunAndClearInterrupts ();
674679 }
675680 running_nested_loop_ = false ;
681+
682+ per_process::Debug (DebugCategory::INSPECTOR_CLIENT, " Exited nested loop\n " );
676683 }
677684
678685 double currentTimeMS () override {
@@ -759,27 +766,11 @@ bool Agent::Start(const std::string& path,
759766 }
760767 }, parent_env_);
761768
762- bool wait_for_connect = options.wait_for_connect ();
763- bool should_break_first_line = options.should_break_first_line ();
764- if (parent_handle_) {
765- should_break_first_line = parent_handle_->WaitForConnect ();
766- parent_handle_->WorkerStarted (client_->getThreadHandle (),
767- should_break_first_line);
768- } else if (!options.inspector_enabled || !options.allow_attaching_debugger ||
769- !StartIoThread ()) {
769+ if (!parent_handle_ &&
770+ (!options.inspector_enabled || !options.allow_attaching_debugger ||
771+ !StartIoThread ())) {
770772 return false ;
771773 }
772-
773- if (wait_for_connect || should_break_first_line) {
774- // Patch the debug options to implement waitForDebuggerOnStart for
775- // the NodeWorker.enable method.
776- if (should_break_first_line) {
777- CHECK (!parent_env_->has_serialized_options ());
778- debug_options_.EnableBreakFirstLine ();
779- parent_env_->options ()->get_debug_options ()->EnableBreakFirstLine ();
780- }
781- client_->waitForFrontend ();
782- }
783774 return true ;
784775}
785776
@@ -1038,6 +1029,33 @@ void Agent::WaitForConnect() {
10381029 client_->waitForFrontend ();
10391030}
10401031
1032+ bool Agent::WaitForConnectByOptions () {
1033+ if (client_ == nullptr ) {
1034+ return false ;
1035+ }
1036+
1037+ bool wait_for_connect = debug_options_.wait_for_connect ();
1038+ bool should_break_first_line = debug_options_.should_break_first_line ();
1039+ if (parent_handle_) {
1040+ should_break_first_line = parent_handle_->WaitForConnect ();
1041+ parent_handle_->WorkerStarted (client_->getThreadHandle (),
1042+ should_break_first_line);
1043+ }
1044+
1045+ if (wait_for_connect || should_break_first_line) {
1046+ // Patch the debug options to implement waitForDebuggerOnStart for
1047+ // the NodeWorker.enable method.
1048+ if (should_break_first_line) {
1049+ CHECK (!parent_env_->has_serialized_options ());
1050+ debug_options_.EnableBreakFirstLine ();
1051+ parent_env_->options ()->get_debug_options ()->EnableBreakFirstLine ();
1052+ }
1053+ client_->waitForFrontend ();
1054+ return true ;
1055+ }
1056+ return false ;
1057+ }
1058+
10411059void Agent::StopIfWaitingForConnect () {
10421060 if (client_ == nullptr ) {
10431061 return ;
0 commit comments