diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-11-26 23:09:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-26 23:09:48 +0100 |
commit | 3a320db27014925bb40f10dd4e706302bc06c1f1 (patch) | |
tree | 5b5b8bd9a925960a454b825949c950b09467c7b4 /core/inspector.rs | |
parent | d8ab492d016f45346002ae0e9bceac7e900b670a (diff) |
fix(inspector): send "isDefault" in aux data (#16836)
With trial and error I found that most debuggers expect "isDefault" to be sent
in "auxData" field of "executionContextCreated" notification. This stems from
the fact that Node.js sends this data and eg. VSCode requires it to close
connection to the debugger when the program finishes execution.
Diffstat (limited to 'core/inspector.rs')
-rw-r--r-- | core/inspector.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/inspector.rs b/core/inspector.rs index daedd291d..e3db65afe 100644 --- a/core/inspector.rs +++ b/core/inspector.rs @@ -150,6 +150,7 @@ impl JsRuntimeInspector { pub fn new( isolate: &mut v8::OwnedIsolate, context: v8::Global<v8::Context>, + is_main: bool, ) -> Rc<RefCell<Self>> { let scope = &mut v8::HandleScope::new(isolate); @@ -183,13 +184,26 @@ impl JsRuntimeInspector { // Tell the inspector about the global context. let context = v8::Local::new(scope, context); let context_name = v8::inspector::StringView::from(&b"global context"[..]); - let aux_data = v8::inspector::StringView::from(&b""[..]); + // NOTE(bartlomieju): this is what Node.js does and it turns out some + // debuggers (like VSCode) rely on this information to disconnect after + // program completes + let aux_data = if is_main { + r#"{"isDefault": true}"# + } else { + r#"{"isDefault": false}"# + }; + let aux_data_view = v8::inspector::StringView::from(aux_data.as_bytes()); self_ .v8_inspector .borrow_mut() .as_mut() .unwrap() - .context_created(context, Self::CONTEXT_GROUP_ID, context_name, aux_data); + .context_created( + context, + Self::CONTEXT_GROUP_ID, + context_name, + aux_data_view, + ); // Poll the session handler so we will get notified whenever there is // new incoming debugger activity. |