fix(debug): support multi-process debug attach and Jazelle runfiles layout#72
Merged
fix(debug): support multi-process debug attach and Jazelle runfiles layout#72
Conversation
…ayout Consolidate debug attach logic into a single method that detaches from wrapper processes and reattaches to each new endpoint. Fixes breakpoint debugging in Jazelle/Bazel multi-process environments. Also fix remote root resolution to handle both standard Bazel (nested targetName_/) and Jazelle (flat) runfiles layouts.
Update test messages to use realistic ws:// URLs that the new endpoint parser can extract. Replace single-attach test with reattach test that verifies detach-and-reattach behavior across multiple endpoints.
mnoah1
requested changes
Mar 6, 2026
- Restore fallback to configured launch profile when no ws:// endpoint is present (fixes Java/Python debug flow) - Return early and keep session alive when continue fails during reattach instead of unconditionally stopping - Skip reattach when the same endpoint appears again
mnoah1
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes breakpoint debugging in Jazelle/Bazel multi-process environments by:
untar.js->execute-command.js->yarn->jest) instead of attaching to the first endpoint and stopping. When a new endpoint appears, it resumes the current wrapper, detaches, and attaches to the new one. Last endpoint wins.getDebugRemoteRootnow checks which runfiles layout exists on disk — standard Bazel (test_/test.runfiles/__main__) vs Jazelle (test.runfiles/__main__) — instead of always assuming the nested layout.Problem
Three issues prevented breakpoint debugging from working in Jazelle environments:
1. Multi-endpoint debug attachment
The original extension attached to the first
Debugger listening onendpoint and stopped looking. Jazelle/Bazel spawns a chain of wrapper Node processes, each emitting its own debug endpoint. The debugger was attaching to a wrapper (e.g.untar.js) instead of the actual Jest test runner.2. Wrong remote root path
getDebugRemoteRootwas generating.../test_/test.runfiles/__main__but Jazelle's actual layout is.../test.runfiles/__main__(notest_/prefix). Breakpoints couldn't bind because the debugger was mapping local files to a path that didn't exist at runtime.3. Missing launch config for source maps
The "Attach to Bazel Test" launch config was missing
sourceMaps: true,resolveSourceMapLocations, and.pnp.cjsinskipFiles. Without these, the debugger couldn't resolve babel-jest's source maps back to the original.tsfiles, and it was pausing on Yarn's PnP bootstrap instead of at breakpoints. (This is alaunch.jsonchange on the user side, not in this PR.)Changes
src/test-runner/run-tracker.ts: Replaced the single-attach debug flow withattachDebugger()— a single method that detaches any existing session and attaches to the new endpoint. RemovedhasDebugSessionBeenInitiatedflag (replaced by checkingvscode.debug.activeDebugSessiondirectly).src/language-tools/typescript.ts:getDebugRemoteRootnow usesfs.existsSyncto check for the nestedtargetName_/directory and includes it only if present.Test plan