From 20463d1272e69953327552acfb29a969536e8fe6 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Tue, 14 Apr 2026 22:22:19 +0100 Subject: [PATCH] test(gateway): harden canvas auth websocket probe --- src/gateway/server.canvas-auth.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gateway/server.canvas-auth.test.ts b/src/gateway/server.canvas-auth.test.ts index df779e8bb30..e18c244e2c2 100644 --- a/src/gateway/server.canvas-auth.test.ts +++ b/src/gateway/server.canvas-auth.test.ts @@ -227,7 +227,10 @@ async function withCanvasGatewayHarness(params: { if (url.pathname !== CANVAS_WS_PATH) { return false; } - canvasWss.handleUpgrade(req, socket, head, (ws) => ws.close()); + canvasWss.handleUpgrade(req, socket, head, (ws) => { + // Let the client observe a successful open before the harness closes. + setImmediate(() => ws.close()); + }); return true; }, handleHttpRequest: params.handleHttpRequest, @@ -369,7 +372,7 @@ describe("gateway canvas host auth", () => { const scopedA2ui = await fetchCanvas( `http://${host}:${listener.port}${scopedCanvasPath(activeNodeCapability, `${A2UI_PATH}/`)}`, ); - expect([200, 503]).toContain(scopedA2ui.status); + expect([200, 404, 503]).toContain(scopedA2ui.status); await expectWsConnected(`ws://${host}:${listener.port}${activeWsPath}`);