diff --git a/apps/t3/scripts/smoke-test.mjs b/apps/t3/scripts/smoke-test.mjs index d39cd7aa06..76d1dcb6f9 100644 --- a/apps/t3/scripts/smoke-test.mjs +++ b/apps/t3/scripts/smoke-test.mjs @@ -1597,6 +1597,49 @@ async function main() { }); }); + await new Promise((resolve, reject) => { + const timer = setTimeout( + () => reject(new Error("Smoke test failed: binary websocket app.health request timed out.")), + 20_000, + ); + const onMessage = (event) => { + let message; + try { + message = JSON.parse(String(event.data)); + } catch { + return; + } + + if (message.type !== "response" || message.id !== "smoke-binary-health") { + return; + } + if ( + message.ok !== true || + message.result?.status !== "ok" || + message.result?.launchCwd !== appRoot + ) { + clearTimeout(timer); + ws.removeEventListener("message", onMessage); + reject(new Error("Smoke test failed: binary websocket app.health response mismatch.")); + return; + } + + clearTimeout(timer); + ws.removeEventListener("message", onMessage); + resolve(); + }; + + ws.addEventListener("message", onMessage); + const encodedBinaryRequest = new TextEncoder().encode( + JSON.stringify({ + type: "request", + id: "smoke-binary-health", + method: "app.health", + }), + ); + ws.send(encodedBinaryRequest); + }); + const bootstrapResponse = await sendWsRequest(ws, { id: "smoke-bootstrap", method: "app.bootstrap",