File tree 5 files changed +25
-11
lines changed
5 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -675,6 +675,14 @@ inline void Environment::set_has_run_bootstrapping_code(bool value) {
675
675
has_run_bootstrapping_code_ = value;
676
676
}
677
677
678
+ inline bool Environment::has_serialized_options () const {
679
+ return has_serialized_options_;
680
+ }
681
+
682
+ inline void Environment::set_has_serialized_options (bool value) {
683
+ has_serialized_options_ = value;
684
+ }
685
+
678
686
inline bool Environment::is_main_thread () const {
679
687
return flags_ & kIsMainThread ;
680
688
}
Original file line number Diff line number Diff line change @@ -862,6 +862,9 @@ class Environment {
862
862
inline bool has_run_bootstrapping_code () const ;
863
863
inline void set_has_run_bootstrapping_code (bool has_run_bootstrapping_code);
864
864
865
+ inline bool has_serialized_options () const ;
866
+ inline void set_has_serialized_options (bool has_serialized_options);
867
+
865
868
static uint64_t AllocateThreadId ();
866
869
static constexpr uint64_t kNoThreadId = -1 ;
867
870
@@ -1106,6 +1109,8 @@ class Environment {
1106
1109
std::unordered_map<std::string, uint64_t > performance_marks_;
1107
1110
1108
1111
bool has_run_bootstrapping_code_ = false ;
1112
+ bool has_serialized_options_ = false ;
1113
+
1109
1114
bool can_call_into_js_ = true ;
1110
1115
Flags flags_;
1111
1116
uint64_t thread_id_;
Original file line number Diff line number Diff line change @@ -728,18 +728,12 @@ bool Agent::Start(const std::string& path,
728
728
return false ;
729
729
}
730
730
731
- // TODO(joyeecheung): we should not be using process as a global object
732
- // to transport --inspect-brk. Instead, the JS land can get this through
733
- // require('internal/options') since it should be set once CLI parsing
734
- // is done.
731
+ // Patch the debug options to implement waitForDebuggerOnStart for
732
+ // the NodeWorker.enable method.
735
733
if (wait_for_connect) {
736
- HandleScope scope (parent_env_->isolate ());
737
- parent_env_->process_object ()->DefineOwnProperty (
738
- parent_env_->context (),
739
- FIXED_ONE_BYTE_STRING (parent_env_->isolate (), " _breakFirstLine" ),
740
- True (parent_env_->isolate ()),
741
- static_cast <v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum))
742
- .FromJust ();
734
+ CHECK (!parent_env_->has_serialized_options ());
735
+ debug_options_.EnableBreakFirstLine ();
736
+ parent_env_->options ()->get_debug_options ()->EnableBreakFirstLine ();
743
737
client_->waitForFrontend ();
744
738
}
745
739
return true ;
Original file line number Diff line number Diff line change @@ -571,6 +571,7 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) {
571
571
return env->ThrowError (
572
572
" Should not query options before bootstrapping is done" );
573
573
}
574
+ env->set_has_serialized_options (true );
574
575
575
576
Isolate* isolate = env->isolate ();
576
577
Local<Context> context = env->context ();
Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ class DebugOptions : public Options {
75
75
76
76
HostPort host_port{" 127.0.0.1" , kDefaultInspectorPort };
77
77
78
+ // Used to patch the options as if --inspect-brk is passed.
79
+ void EnableBreakFirstLine () {
80
+ inspector_enabled = true ;
81
+ break_first_line = true ;
82
+ }
83
+
78
84
bool wait_for_connect () const {
79
85
return break_first_line || break_node_first_line;
80
86
}
You can’t perform that action at this time.
0 commit comments