From 0f6dd6a3ed3f0899b618a0958161e8a0b3b63be2 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 00:16:50 +0000 Subject: [PATCH] Assert websocket hello payload in smoke test handshake Co-authored-by: Theo Browne --- apps/t3/scripts/smoke-test.mjs | 37 ++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/apps/t3/scripts/smoke-test.mjs b/apps/t3/scripts/smoke-test.mjs index b60aee72a7..9344f29226 100644 --- a/apps/t3/scripts/smoke-test.mjs +++ b/apps/t3/scripts/smoke-test.mjs @@ -180,6 +180,14 @@ async function main() { const ws = new WebSocket(wsUrl); await new Promise((resolve, reject) => { + let sawHello = false; + let sawHealthResponse = false; + const tryResolve = () => { + if (sawHello && sawHealthResponse) { + clearTimeout(timer); + resolve(); + } + }; const timer = setTimeout( () => reject(new Error("Smoke test failed: websocket did not respond in time.")), 20_000, @@ -195,6 +203,31 @@ async function main() { }); ws.addEventListener("message", (event) => { const message = JSON.parse(String(event.data)); + if (message.type === "hello") { + if (message.version !== 1) { + clearTimeout(timer); + reject( + new Error( + `Smoke test failed: expected hello version 1, got ${String(message.version)}.`, + ), + ); + return; + } + if (message.launchCwd !== appRoot) { + clearTimeout(timer); + reject( + new Error( + `Smoke test failed: expected hello launch cwd ${appRoot}, got ${String( + message.launchCwd, + )}.`, + ), + ); + return; + } + sawHello = true; + tryResolve(); + return; + } if (message.type !== "response" || message.id !== "smoke" || message.ok !== true) { return; } @@ -233,8 +266,8 @@ async function main() { return; } - clearTimeout(timer); - resolve(); + sawHealthResponse = true; + tryResolve(); }); ws.addEventListener("error", () => { clearTimeout(timer);