Repository navigation
Closed
Labels
bugSomething isn't working
Description
Summary
MCP integration tests (mcp-serve.integration.test.ts, mcp-e2e.integration.test.ts) are now failing consistently in CI, not just intermittently. This was observed on both the #490 branch and main during the same timeframe.
Failing Tests (8 total)
mcp-e2e.integration.test.ts> Graceful shutdown > AC-8: should disconnect SSE client cleanly on SIGTERMmcp-serve.integration.test.ts> AC-16: graceful shutdown > should exit cleanly on SIGTERM for SSE servermcp-serve.integration.test.ts> AC-16: graceful shutdown > should exit cleanly on SIGINT for SSE servermcp-serve.integration.test.ts> AC-11: MCP client detection > should detect MCP client config paths for current platformmcp-serve.integration.test.ts> AC-11: MCP client detection > should generate valid sequant MCP config entrymcp-serve.integration.test.ts> AC-11: MCP client detection > should add sequant config to an existing MCP config filemcp-serve.integration.test.ts> AC-11: MCP client detection > should create config file and parent directories if they don't existmcp-serve.integration.test.ts> error scenarios > should handle port already in use for SSE transport
Root Cause
The afterEach hook at mcp-serve.integration.test.ts:114 times out at 60s (vitest default hookTimeout). It kills process groups via SIGKILL and waits for exit, but the promise never resolves — likely because:
- The spawned process group has already exited by the time the listener is registered (race condition between
proc.exitCodecheck andproc.on("exit", ...)) - OR GitHub Actions runner changes affected process group signal delivery
History
- Originally fixed in 2026-03-23 with
detached: true+ process group signaling - Was documented as "passes consistently in GitHub Actions CI" but that is no longer true
- Observed failing consistently on main as of 2026-04-06 (run IDs: 24022361055, 24022099503)
Acceptance Criteria
-
afterEachcleanup handles the race condition where process exits before listener is registered - Add explicit timeout to the exit promise (e.g., 5s) with forced resolution to prevent 60s hangs
- All 8 tests pass consistently in CI (run 3x to verify)
- Update
project_ci_known_failures.mdmemory to reflect current status
Suggested Fix
afterEach(async () => {
const exitPromises = spawnedProcesses.map(
(proc) =>
new Promise<void>((resolve) => {
if (proc.exitCode !== null || proc.killed) {
resolve();
return;
}
const timeout = setTimeout(() => resolve(), 5000);
proc.on("exit", () => {
clearTimeout(timeout);
resolve();
});
killProcessGroup(proc, "SIGKILL");
}),
);
await Promise.all(exitPromises);
spawnedProcesses.length = 0;
});Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
admarble commentedon Apr 6, 2026
→ PROCEED — MCP integration test afterEach race condition, fix + 3x CI verify
exec → qa · 4 ACs · bug fix (no spec needed)
CI failing on main — unblocks other PRs.
fix(#492): resolve afterEach race condition in MCP integration tests
fix(#492): apply same afterEach race fix to multi-client test
admarble commentedon Apr 6, 2026
/fullsolve Complete
Status: READY_FOR_MERGE
AC Coverage
proc.signalCode !== nullcheck to detect signal-killed processesclearTimeouton normal exitproject_ci_known_failures.mdSummary
mcp-serve.integration.test.ts,mcp-e2e.integration.test.ts,mcp-serve-multi-client.integration.test.ts)afterEachcheckedproc.exitCodeandproc.killedbut notproc.signalCode— signal-killed processes haveexitCode=nullandkilled=false, so the exit listener was registered after the event already firedproc.signalCode !== nullto early-exit check + 5s timeout fallbackmcp-serve-multi-client.integration.test.tsPR: #493
admarble commentedon Apr 6, 2026
Documentation Review Complete
This issue is a test infrastructure bug fix — no user-facing documentation required.
Changes (all in
__tests__/integration/):mcp-serve.integration.test.ts— fixedafterEachrace conditionmcp-e2e.integration.test.ts— fixedafterEachrace conditionmcp-serve-multi-client.integration.test.ts— fixed same pattern (found during QA sweep)Why no docs:
signalCodecheck + timeout fallback)Internal reference:
project_ci_known_failures.mdmemory updated to reflect fix statusNo documentation action needed.
fix(#492): resolve afterEach race condition in MCP integration tests
fix(#492): apply same afterEach race fix to multi-client test