From 598e28462a5bd025b267ea0777aa613054de8907 Mon Sep 17 00:00:00 2001 From: Zakir Jiwani Date: Wed, 1 Apr 2026 02:38:44 -0400 Subject: [PATCH] Suppress SSE proxy errors on expected upstream socket close (#799) When the upstream OpenCode process restarts, the fetch connection is terminated by the remote side (UND_ERR_SOCKET / "other side closed"). Previously the catch block would log this as a warning and the VSCode sseProxy would reject its run promise (sending an error to the webview) even though the termination was normal. Now both handlers treat UND_ERR_SOCKET the same way they treat an explicit abort. Co-authored-by: Bohdan Triapitsyn --- packages/vscode/src/sseProxy.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/vscode/src/sseProxy.ts b/packages/vscode/src/sseProxy.ts index 67826e56..28009035 100644 --- a/packages/vscode/src/sseProxy.ts +++ b/packages/vscode/src/sseProxy.ts @@ -126,10 +126,17 @@ export const openSseProxy = async ({ const result = await connect(); const run = (async () => { - for await (const _ of result.stream) { - void _; - if (signal.aborted) { - break; + try { + for await (const _ of result.stream) { + void _; + if (signal.aborted) { + break; + } + } + } catch (error: unknown) { + const cause = (error as { cause?: { code?: string } } | null)?.cause; + if (!signal.aborted && cause?.code !== 'UND_ERR_SOCKET') { + throw error; } } })();