From bb642b19483c4940896b47038681a9a9ffd5b914 Mon Sep 17 00:00:00 2001 From: anthony bushong Date: Tue, 16 Sep 2025 15:29:11 -0700 Subject: [PATCH] fix(tests): reduce flakiness in simple mcp server test (#8583) --- integration-tests/simple-mcp-server.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/integration-tests/simple-mcp-server.test.ts b/integration-tests/simple-mcp-server.test.ts index c7af1d431b..d8b6268d01 100644 --- a/integration-tests/simple-mcp-server.test.ts +++ b/integration-tests/simple-mcp-server.test.ts @@ -189,6 +189,25 @@ describe('simple-mcp-server', () => { const { chmodSync } = await import('node:fs'); chmodSync(testServerPath, 0o755); } + + // Poll for script for up to 5s + const { accessSync, constants } = await import('node:fs'); + const isReady = await rig.poll( + () => { + try { + accessSync(testServerPath, constants.F_OK); + return true; + } catch { + return false; + } + }, + 5000, // Max wait 5 seconds + 100, // Poll every 100ms + ); + + if (!isReady) { + throw new Error('MCP server script was not ready in time.'); + } }); it('should add two numbers', async () => {