From 9b3594748ca0385ae15b095f6b8cd124d89c10f3 Mon Sep 17 00:00:00 2001 From: breken Date: Thu, 24 Sep 2026 06:55:09 -0700 Subject: [PATCH] :bug: Fix MCP plugin reconnect loop on duplicate connection (#11520) The MCP server closes duplicate plugin connections with 1008 (policy violation). The plugin treated every close as retryable: shouldReconnect stayed true, scheduleReconnect re-armed, and each brief onopen reset the backoff - looping at ~1s until the browser froze. Treat 1008 closes as terminal and stay disconnected until the user reconnects explicitly. --- mcp/packages/plugin/src/main.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mcp/packages/plugin/src/main.ts b/mcp/packages/plugin/src/main.ts index 4cd19e1947..4b57738974 100644 --- a/mcp/packages/plugin/src/main.ts +++ b/mcp/packages/plugin/src/main.ts @@ -255,6 +255,15 @@ function connectToMcpServer(baseUrl?: string, token?: string): void { updateCurrentTask(null); } ws = null; + if (event.code === 1008) { + // Policy violation (e.g. duplicate connection for the same user + // token - another tab already holds the connection). Retrying + // would be refused again immediately, so stay disconnected + // until the user explicitly reconnects. + shouldReconnect = false; + cancelReconnect(); + return; + } scheduleReconnect(); };