Skip to content

fix(#492): resolve afterEach race condition in MCP integration tests - #493

Merged
admarble merged 2 commits into
mainfrom
feature/492-mcp-test-aftereach-race
Apr 6, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/492-mcp-test-aftereach-race

Conversation

@admarble

@admarble admarble commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix race condition in afterEach cleanup across 3 MCP integration test files where signal-killed processes have exitCode=null and killed=false, causing the exit listener to never fire and a 60s timeout hang
  • Add proc.signalCode !== null to the early-exit check + 5s timeout fallback on exit promise
  • Also fixed the same vulnerable pattern in mcp-serve-multi-client.integration.test.ts (found during QA sweep)

Root Cause

When process.kill(-pid, signal) kills a process group, Node.js sets signalCode but leaves exitCode=null and killed=false. The old code only checked exitCode and killed, missed the already-exited process, registered an exit listener after the event had already fired, and hung for 60s.

Test plan

  • All 29 MCP integration tests pass (3 test files)
  • Ran 3x locally to verify consistency
  • Full test suite passes (2410 tests, 99 files, 0 failures)
  • CI passes 3x (AC-3 verification)

Fixes #492

admarble added 2 commits April 6, 2026 09:33
The afterEach cleanup checked proc.exitCode and proc.killed to detect
already-exited processes, but signal-killed processes have exitCode=null
and killed=false (process.kill(-pid) doesn't set killed). This caused
the exit listener to be registered after the event had already fired,
resulting in a promise that never resolved and a 60s timeout.

Fix: check proc.signalCode !== null in the early-exit condition, and add
a 5s timeout fallback on the exit promise as belt-and-suspenders.

Fixes #492

Entire-Checkpoint: bb61dc5abe0c
Same signalCode check + timeout fix as the other two MCP integration
test files. Found during QA sweep for identical vulnerable patterns.

Entire-Checkpoint: f138b7c866fc
@admarble
admarble merged commit 57c6416 into main Apr 6, 2026
5 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.

fix: MCP integration tests consistently timing out in CI

1 participant