Skip to content

fix(debug): support multi-process debug attach and Jazelle runfiles layout#72

Merged
mnoah1 merged 3 commits intouber:mainfrom
harunaOseni:debug-attach-flow
Mar 10, 2026
Merged

fix(debug): support multi-process debug attach and Jazelle runfiles layout#72
mnoah1 merged 3 commits intouber:mainfrom
harunaOseni:debug-attach-flow

Conversation

@harunaOseni
Copy link
Copy Markdown
Contributor

@harunaOseni harunaOseni commented Mar 5, 2026

Summary

Fixes breakpoint debugging in Jazelle/Bazel multi-process environments by:

  • Multi-endpoint debug attachment: The extension now follows the full process chain (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.
  • Correct remote root path resolution: getDebugRemoteRoot now 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 on endpoint 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

getDebugRemoteRoot was generating .../test_/test.runfiles/__main__ but Jazelle's actual layout is .../test.runfiles/__main__ (no test_/ 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.cjs in skipFiles. Without these, the debugger couldn't resolve babel-jest's source maps back to the original .ts files, and it was pausing on Yarn's PnP bootstrap instead of at breakpoints. (This is a launch.json change on the user side, not in this PR.)

Changes

  • src/test-runner/run-tracker.ts: Replaced the single-attach debug flow with attachDebugger() — a single method that detaches any existing session and attaches to the new endpoint. Removed hasDebugSessionBeenInitiated flag (replaced by checking vscode.debug.activeDebugSession directly).
  • src/language-tools/typescript.ts: getDebugRemoteRoot now uses fs.existsSync to check for the nested targetName_/ directory and includes it only if present.

Test plan

  • Verified breakpoint debugging works in Jazelle/Bazel Jest tests (multi-process chain)
  • Verified standard Bazel debug flow is unaffected (single endpoint, nested runfiles layout)

…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.
Comment thread src/test-runner/run-tracker.ts
Comment thread src/test-runner/run-tracker.ts
Comment thread src/test-runner/run-tracker.ts
Comment thread src/test/suite/run-tracker.test.ts
- 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 mnoah1 merged commit 3c4c4ef into uber:main Mar 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants