From 040eab93199bb9136233f014f5d0d1f376b404d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Feb 2026 13:31:34 +0000 Subject: [PATCH] fix(message-transport): only ignore messages that lack jsonrpc: "2.0" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tighten the parse-failure handler: silently ignore postMessage frames where event.data?.jsonrpc !== "2.0" (i.e. not JSON-RPC at all — null, undefined, a primitive, or an object from the host environment that doesn't carry the jsonrpc field). Messages that do carry jsonrpc: "2.0" but are otherwise malformed still surface via onerror so genuine protocol errors aren't swallowed. https://claude.ai/code/session_01DaJpUtSJf4hA7tnu3nJz8s --- src/message-transport.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/message-transport.ts b/src/message-transport.ts index c49aa77c6..dded70469 100644 --- a/src/message-transport.ts +++ b/src/message-transport.ts @@ -82,7 +82,17 @@ export class PostMessageTransport implements Transport { if (parsed.success) { console.debug("Parsed message", parsed.data); this.onmessage?.(parsed.data); + } else if (event.data?.jsonrpc !== "2.0") { + // Not a JSON-RPC message at all (e.g. internal frames injected by + // the host environment). Ignore silently so the transport stays alive. + console.debug( + "Ignoring non-JSON-RPC message", + parsed.error.message, + event, + ); } else { + // Has jsonrpc: "2.0" but is otherwise malformed — surface as a real + // protocol error. console.error("Failed to parse message", parsed.error.message, event); this.onerror?.( new Error(