Skip to content

test: drive the MCP heartbeat test with one controlled tick - #380

Merged
oddessentials merged 1 commit into
mainfrom
fix/mcp-heartbeat-test
Nov 7, 2026
Merged

oddessentials merged 1 commit into
mainfrom
fix/mcp-heartbeat-test

Conversation

@oddessentials

Copy link
Copy Markdown
Owner

Removes a timing dependency from one required test. No production code changes.

an open page hears an MCP server removed outside the card, from the heartbeat failed on Test (macos-latest, Node 22) in release run 42325109131, which cancelled the release of #379.

Cause: the test set heartbeatMs: 20. The heartbeat is also the socket's liveness check, so one pause in the test process while a ping was unanswered could terminate the socket before its only providers.updated arrived. The test then waited out its 10 s guard. A throwaway reproduction with an injected pause gave this result in 5 of 5 runs. The CI log doesn't record the close, so this shows the mechanism produces this failure, not that it is what happened in that run.

Fix: mock setInterval and fire one controlled tick after the external change. One tick can't terminate the socket, because the liveness check takes two. The real refresh and WebSocket broadcast still run, and the 10 s guard is unchanged.

Checks

Run locally at a87ef8d, with temporary edits that were then restored:

  • The client saw 1 ping and 1 real providers.updated reporting off.
  • The test fails with "the card never heard the change" when the heartbeat refresh is disabled, and when the broadcast is disabled.
  • With a 100 ms pause before the tick, it passes and the socket stays open.

On Windows, tests/mcp-connect.test.mjs passes 18 of 18, npm test has 1203 passed, 0 failed and 75 skipped, and all 12 browser tests and tests/release/plan.mjs pass. The fixed test also passes on Node 22.

🤖 Generated with Claude Code

The test's 20 ms heartbeat was also a 20 ms liveness deadline, so one pause while
a ping was unanswered ended the socket before its only providers.updated arrived,
and the test waited out its failure guard. One mocked tick can't end the socket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oddessentials
oddessentials merged commit 8b9cd2f into main Nov 7, 2026
35 checks passed
@oddessentials
oddessentials deleted the fix/mcp-heartbeat-test branch November 7, 2026 02:53
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.

1 participant