From f04d1204f99eab9f9e4cb1cbeb5bd2efd29d4fd0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Feb 2026 23:50:58 +0000 Subject: [PATCH] Guard runtime websocket sends against state races Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/t3/src/runtimeApiServer.ts b/apps/t3/src/runtimeApiServer.ts index ce0c18b1b4..3b8961f23d 100644 --- a/apps/t3/src/runtimeApiServer.ts +++ b/apps/t3/src/runtimeApiServer.ts @@ -142,7 +142,11 @@ function sendMessage(socket: WebSocket, message: unknown): void { return; } - socket.send(JSON.stringify(message)); + try { + socket.send(JSON.stringify(message)); + } catch { + // Best-effort event delivery. Socket may have transitioned states. + } } function decodeClientMessage(raw: RawData): string | null {