From 8bd155f790d40357e87ac0e2af6cec09af25c890 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Feb 2026 23:13:04 +0000 Subject: [PATCH] Cover arraybuffer websocket request decoding Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.test.ts | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index 615a597651..61b3049253 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -164,6 +164,40 @@ describe("runtimeApiServer", () => { client.socket.close(); }); + it("accepts arraybuffer-encoded websocket request payloads", async () => { + const server = await startRuntimeApiServer({ + port: 0, + launchCwd: process.cwd(), + }); + servers.push(server); + + const client = await connectClient(server.wsUrl); + await client.nextMessage(); + + const encoded = new TextEncoder().encode( + JSON.stringify({ + type: "request", + id: "arraybuffer-todos-1", + method: "todos.list", + }), + ); + client.socket.send(encoded.buffer); + + const response = await withTimeout( + (async (): Promise => { + const message = await client.nextMessage(); + if (message.type === "response" && message.id === "arraybuffer-todos-1") { + return message; + } + return Promise.reject(new Error("Expected matching todos response.")); + })(), + ); + expect(response.ok).toBe(true); + expect(Array.isArray(response.result)).toBe(true); + + client.socket.close(); + }); + it("replaces an existing websocket client with a new one", async () => { const server = await startRuntimeApiServer({ port: 0,