diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-11-27 00:44:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 00:44:39 +0100 |
commit | d4f659d1d3caa550dfc15ca9e62d4ad6a31db7ac (patch) | |
tree | 55479431116f0d70b156728a4c648ded7924aa01 /core/runtime.rs | |
parent | 6344b9e0a5a9cc434953c16d3dc6a6e4f052d4dd (diff) |
feat(core): send "executionContextDestroyed" notification on program end (#16831)
This commit changes "JsRuntime" to send "executionContextDestroyed"
notification when the program finishes and shows a prompt informing
that runtime is waiting for inspector to disconnect.
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 8cb38de2f..9ee3aad70 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -1099,9 +1099,21 @@ impl JsRuntime { let pending_state = self.event_loop_pending_state(); if !pending_state.is_pending() && !maybe_scheduling { if has_inspector { - let inspector_has_active_sessions = - self.inspector().borrow_mut().has_active_sessions(); - if wait_for_inspector && inspector_has_active_sessions { + let inspector = self.inspector(); + let has_active_sessions = inspector.borrow().has_active_sessions(); + let has_blocking_sessions = inspector.borrow().has_blocking_sessions(); + + if wait_for_inspector && has_active_sessions { + // If there are no blocking sessions (eg. REPL) we can now notify + // debugger that the program has finished running and we're ready + // to exit the process once debugger disconnects. + if !has_blocking_sessions { + let context = self.global_context(); + let scope = &mut self.handle_scope(); + inspector.borrow_mut().context_destroyed(scope, context); + println!("Program finished. Waiting for inspector to disconnect to exit the process..."); + } + return Poll::Pending; } } |