@@ -487,6 +487,8 @@ class NodeInspectorClient : public V8InspectorClient {
487
487
}
488
488
489
489
if (interface_) {
490
+ per_process::Debug (DebugCategory::INSPECTOR_CLIENT,
491
+ " Stopping waiting for frontend events\n " );
490
492
interface_->StopWaitingForFrontendEvent ();
491
493
}
492
494
}
@@ -668,11 +670,16 @@ class NodeInspectorClient : public V8InspectorClient {
668
670
669
671
running_nested_loop_ = true ;
670
672
673
+ per_process::Debug (DebugCategory::INSPECTOR_CLIENT,
674
+ " Entering nested loop\n " );
675
+
671
676
while (shouldRunMessageLoop ()) {
672
677
if (interface_) interface_->WaitForFrontendEvent ();
673
678
env_->RunAndClearInterrupts ();
674
679
}
675
680
running_nested_loop_ = false ;
681
+
682
+ per_process::Debug (DebugCategory::INSPECTOR_CLIENT, " Exited nested loop\n " );
676
683
}
677
684
678
685
double currentTimeMS () override {
@@ -759,27 +766,11 @@ bool Agent::Start(const std::string& path,
759
766
}
760
767
}, parent_env_);
761
768
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 ())) {
770
772
return false ;
771
773
}
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
- }
783
774
return true ;
784
775
}
785
776
@@ -1038,6 +1029,33 @@ void Agent::WaitForConnect() {
1038
1029
client_->waitForFrontend ();
1039
1030
}
1040
1031
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
+
1041
1059
void Agent::StopIfWaitingForConnect () {
1042
1060
if (client_ == nullptr ) {
1043
1061
return ;
0 commit comments