Skip to content

test(attach): eliminate ephemeral-port TOCTOU races in attach integration suites - #1243

Merged
debugmcpdev merged 1 commit into
mainfrom
fix/test-attach-port-race
Nov 23, 2026
Merged

debugmcpdev merged 1 commit into
mainfrom
fix/test-attach-port-race

Conversation

@debugmcpdev

Copy link
Copy Markdown
Collaborator

Summary

Fixes an ephemeral-port TOCTOU collision (RuntimeError: Can't listen for client connections: [Errno 98] Address already in use) observed in CI during parallel Vitest execution:

  • tests/adapters/javascript/integration/javascript-subprocess-attach.test.ts & tests/adapters/javascript/integration/javascript-attach-idle.test.ts: pass --inspect=127.0.0.1:0 directly to node and parse the kernel-assigned inspector port from Debugger listening on ws://127.0.0.1:<port>/, removing getFreePort() and eliminating the close-to-bind window altogether.
  • tests/adapters/python/integration/python-subprocess-attach.test.ts: retry startTargetOnce up to 4 times when debugpy --listen hits Address already in use / EADDRINUSE / 10048 between getFreePort() closing its probe socket and debugpy binding.

Test Plan

  • Full local Dev-Loop Gate (pnpm lint, pnpm typecheck:all, clean build, pnpm test:unit, pnpm test:integration).

…tion suites

- JavaScript attach integration tests (`javascript-subprocess-attach.test.ts` and
  `javascript-attach-idle.test.ts`) now pass `--inspect=127.0.0.1:0` directly to
  Node and parse the kernel-assigned inspector port from stderr, eliminating the
  probe-socket close-to-bind TOCTOU window completely.
- Python subprocess attach integration test (`python-subprocess-attach.test.ts`)
  retries target startup up to 4 times when a parallel test grabs the ephemeral
  port between `getFreePort()` closing its probe socket and `debugpy --listen`
  binding (`[Errno 98] Address already in use` / `EADDRINUSE` / `10048`).
@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@debugmcpdev
debugmcpdev merged commit ed7373c into main Nov 23, 2026
16 checks passed
@debugmcpdev
debugmcpdev deleted the fix/test-attach-port-race branch November 23, 2026 16:21
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