From a87ef8dc55ad044199989642e4c37a68eb2ff919 Mon Sep 17 00:00:00 2001 From: oddessentials Date: Fri, 6 Nov 2026 21:23:52 -0500 Subject: [PATCH] test: drive the MCP heartbeat test with one controlled tick 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 --- tests/mcp-connect.test.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/mcp-connect.test.mjs b/tests/mcp-connect.test.mjs index 50b37ff..44fb6c8 100644 --- a/tests/mcp-connect.test.mjs +++ b/tests/mcp-connect.test.mjs @@ -457,7 +457,8 @@ test('an open page hears an MCP server removed outside the card, from the heartb const token = 'a'.repeat(48); ctx.registry.mcpState = (provider) => ctx.mcp.describe(provider); const manager = Object.assign(new EventEmitter(), { list: () => [], refreshMultiplexers() {}, sessions: new Map() }); - const api = createManagerServer({ manager, registry: ctx.registry, token, port: 0, webDir: path.join(here, '..', 'web'), mcpConnect: ctx.mcp, heartbeatMs: 20 }); + t.mock.timers.enable({ apis: ['setInterval'] }); + const api = createManagerServer({ manager, registry: ctx.registry, token, port: 0, webDir: path.join(here, '..', 'web'), mcpConnect: ctx.mcp }); await api.listen(); const ws = new WebSocket(`${api.url.replace('http', 'ws')}/api/v1/events`, { headers: { Authorization: `Bearer ${token}` } }); try { @@ -467,6 +468,7 @@ test('an open page hears an MCP server removed outside the card, from the heartb })); await once(ws, 'open'); writeRaw('anthropic', ctx.homeOf('anthropic'), JSON.stringify({ theme: 'dark', mcpServers: {} })); + t.mock.timers.tick(30000); let timer; await Promise.race([off, new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('the card never heard the change')), 10000); })]); clearTimeout(timer);