Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(chat): classify Bun socket close errors (#6486)

Ezra Ellette9f7d34f1f545
diff --git a/apps/screenpipe-app-tauri/lib/chat/__tests__/provider-errors.test.ts b/apps/screenpipe-app-tauri/lib/chat/__tests__/provider-errors.test.ts
index 53ddfdf47..5798b1695 100644
--- a/apps/screenpipe-app-tauri/lib/chat/__tests__/provider-errors.test.ts
+++ b/apps/screenpipe-app-tauri/lib/chat/__tests__/provider-errors.test.ts
@@ -96,6 +96,20 @@ describe("provider error copy", () => {
expect(msg?.toLowerCase()).not.toContain("ollama");
});
+ it("maps Bun socket-close errors to retryable connectivity copy", () => {
+ const raw =
+ "The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()";
+ const presentation = buildProviderErrorPresentation(raw, {
+ provider: "pi",
+ model: "auto",
+ });
+
+ expect(presentation).toMatchObject({ kind: "provider", retryable: true });
+ expect(presentation?.message).toContain("screenpipe cloud");
+ expect(presentation?.message.toLowerCase()).toContain("try again");
+ expect(presentation?.message).not.toContain("verbose: true");
+ });
+
it("maps the gateway TLS-handshake / send-request signatures the same way", () => {
// exact strings observed reaching the app during the 2026-06-18 outage
for (const raw of [
diff --git a/apps/screenpipe-app-tauri/lib/chat/provider-errors.ts b/apps/screenpipe-app-tauri/lib/chat/provider-errors.ts
index 6523d919b..a8090fb65 100644
--- a/apps/screenpipe-app-tauri/lib/chat/provider-errors.ts
+++ b/apps/screenpipe-app-tauri/lib/chat/provider-errors.ts
@@ -93,6 +93,7 @@ function isConnectionLikeError(errorStr: string): boolean {
normalized.includes("connection error") ||
normalized.includes("failed to fetch") ||
normalized.includes("fetch failed") ||
+ normalized.includes("socket connection was closed unexpectedly") ||
normalized.includes("econnrefused") ||
normalized.includes("connection refused") ||
// network/TLS signatures seen reaching the chat from the gateway, e.g. the