From 4e36ebaea070527ffb24ec6c30fd4fa4357b4d65 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Feb 2026 23:24:26 +0000 Subject: [PATCH] Cover runtime tolerance for malformed client messages Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index ffd3c8d2a4..0607e3d0dd 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -177,6 +177,30 @@ describe("runtimeApiServer", () => { client.socket.close(); }); + it("ignores malformed client messages and continues processing", async () => { + const server = await startRuntimeApiServer({ + port: 0, + launchCwd: process.cwd(), + }); + servers.push(server); + + const client = await connectClient(server.wsUrl); + await client.nextMessage(); + + client.socket.send("not-json"); + client.socket.send(JSON.stringify({ type: "request", id: "", method: "" })); + + const response = await sendRequest( + client.socket, + client.nextMessage, + "todos-after-malformed", + "todos.list", + ); + expect(response.ok).toBe(true); + + client.socket.close(); + }); + it("accepts buffer-encoded websocket request payloads", async () => { const server = await startRuntimeApiServer({ port: 0,