diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-12-12 15:33:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-12 15:33:30 +0100 |
commit | 4a17c930882c5765e5fdedb50b6493469f61e32d (patch) | |
tree | 91f7157b871ee5d2414018586fc1e3a335963d53 /core/inspector.rs | |
parent | a2db70a8d0820722695e9094c8dbc888bde1ffa3 (diff) |
feat: add `--inspect-wait` flag (#17001)
This commit adds new "--inspect-wait" flag which works similarly
to "--inspect-brk" in that it waits for inspector session to be
established before running code. However it doesn't break on the first
statement of user code, but instead runs it as soon as a session
is established.
Diffstat (limited to 'core/inspector.rs')
-rw-r--r-- | core/inspector.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/core/inspector.rs b/core/inspector.rs index 8a9136091..b9a5908ed 100644 --- a/core/inspector.rs +++ b/core/inspector.rs @@ -349,6 +349,23 @@ impl JsRuntimeInspector { /// This function blocks the thread until at least one inspector client has /// established a websocket connection. + pub fn wait_for_session(&mut self) { + loop { + match self.sessions.get_mut().established.iter_mut().next() { + Some(_session) => { + self.flags.get_mut().waiting_for_session = false; + break; + } + None => { + self.flags.get_mut().waiting_for_session = true; + let _ = self.poll_sessions(None).unwrap(); + } + }; + } + } + + /// This function blocks the thread until at least one inspector client has + /// established a websocket connection. /// /// After that, it instructs V8 to pause at the next statement. /// Frontend must send "Runtime.runIfWaitingForDebugger" message to resume |