From d1ba1ad26f771b4c337a6a0868e9f598c51dbf36 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Tue, 29 Sep 2026 22:44:52 +0800 Subject: [PATCH] fix(vscode): wait for source maps before running debugged tests CI reproduction passed 28/30 runs with Node defaults and 30/30 with source-map pauses. Failing traces show no pool-child instrumentation pause and a breakpoint installed after the target line ran. The passing reference pauses before execution and hits the same generated location. Wait for source maps so in-memory Rstest bundles cannot outrun TypeScript breakpoint binding. Closes #79 --- packages/vscode/AGENTS.md | 2 +- packages/vscode/src/stacks/test/master.ts | 2 ++ packages/vscode/tests/stacks/test/master.test.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vscode/AGENTS.md b/packages/vscode/AGENTS.md index c9ce8aa..02cc2b0 100644 --- a/packages/vscode/AGENTS.md +++ b/packages/vscode/AGENTS.md @@ -23,7 +23,7 @@ One extension replacing the standalone `rstack.rslint` and `rstack.rstest` exten 10. **Test file ownership** (test) — publication mirrors the CLI per project. When a request carries the same file or the same case from several projects (merged gutter, run-at-cursor, run-current-file; all three profiles reach `startTestRun`), only items of the deepest project root run and the others are reported skipped to clear stale merged gutter state — implemented in `runRouting.ts`, `index.ts` (`startTestRun`), and `master.ts` (`RstestApi.project` made public). Explicit single-project selections, project/folder/Run All, and `rstack.rstest.runInTerminal` (VS Code supplies one explicitly picked item) keep CLI scope. -11. **Debugger-owned test processes** (test) — debug runs use js-debug `launch` with child-process auto-attach instead of upstream's `--inspect-wait` plus `attach`. js-debug owns inspector endpoints and process teardown; `debuggerPort` / `debuggerAddress` are removed without migration. `debugWorker.ts` owns the session and a debug-only local socket carrying JSON birpc messages (`shared/socketRpc.ts`) after a first-line per-launch secret authenticates the worker; normal runs retain Node IPC. Preserve the 9229-occupied breakpoint and continue/cancel/stop cleanup regression in `e2e/rstest/suite/debug.test.ts` when syncing. +11. **Debugger-owned test processes** (test) — debug runs use js-debug `launch` with child-process auto-attach instead of upstream's `--inspect-wait` plus `attach`, and `pauseForSourceMap: true` lets TypeScript breakpoints bind before in-memory test bundles execute. js-debug owns inspector endpoints and process teardown; `debuggerPort` / `debuggerAddress` are removed without migration. `debugWorker.ts` owns the session and a debug-only local socket carrying JSON birpc messages (`shared/socketRpc.ts`) after a first-line per-launch secret authenticates the worker; normal runs retain Node IPC. Preserve the 9229-occupied breakpoint and continue/cancel/stop cleanup regression in `e2e/rstest/suite/debug.test.ts` when syncing. 12. **Function-title discovery** (test) — `stacks/test/parserTest.ts` replaces upstream's scope pre-pass with walk-order bindings and assignment tracking for runtime-name parity. Unbound identifiers (including default imports) and non-computed members use best-effort identifier/property names rather than giving up with `unnamed test`; known unknown bindings still stay unnamed. Re-apply this adaptation when syncing `parserTest.ts`, preserving the upstream tests and local runtime-parity cases. diff --git a/packages/vscode/src/stacks/test/master.ts b/packages/vscode/src/stacks/test/master.ts index c9b60e2..433b324 100644 --- a/packages/vscode/src/stacks/test/master.ts +++ b/packages/vscode/src/stacks/test/master.ts @@ -826,6 +826,8 @@ export class RstestApi { cwd: this.cwd, env: workerEnv, autoAttachChildProcesses: true, + // In-memory test bundles can execute before TS breakpoints bind with js-debug's Node default (#79). + pauseForSourceMap: true, skipFiles: getConfigValue('debugExclude', this.workspace), ...(debugOutFiles.length ? { outFiles: debugOutFiles } : {}), }, diff --git a/packages/vscode/tests/stacks/test/master.test.ts b/packages/vscode/tests/stacks/test/master.test.ts index 12fd199..00a098e 100644 --- a/packages/vscode/tests/stacks/test/master.test.ts +++ b/packages/vscode/tests/stacks/test/master.test.ts @@ -1340,6 +1340,7 @@ describe('Rstest public API', () => { DEBUG_ONLY: 'yes', RSTEST: 'true', }, + pauseForSourceMap: true, skipFiles: ['**/vendor/**'], outFiles: ['**/compiled/**/*.js'], });