From 503e6d8a7588dbb910c8a1527866727fdd31b9c7 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 06:11:56 +0000 Subject: [PATCH] Assert unauthorized websocket close reason semantics Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index 5d22dc6722..bc5d836798 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -969,12 +969,15 @@ describe("runtimeApiServer", () => { unauthorizedMessageCount += 1; }); const unauthorizedClose = await withTimeout( - new Promise<{ code: number }>((resolve, reject) => { - unauthorizedClient.once("close", (code) => resolve({ code })); + new Promise<{ code: number; reason: string }>((resolve, reject) => { + unauthorizedClient.once("close", (code, reason) => + resolve({ code, reason: reason.toString() }), + ); unauthorizedClient.once("error", (error) => reject(error)); }), ); expect(unauthorizedClose.code).toBe(4001); + expect(unauthorizedClose.reason).toBe("unauthorized"); expect(unauthorizedMessageCount).toBe(0); const wrongTokenUrl = `${authorizedUrl.origin}${authorizedUrl.pathname}?token=wrong-token`;