From e23e9522d152ec29ebd75fded11e57a3d7ab264c Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Sun, 21 Jun 2026 19:20:34 +0800 Subject: [PATCH] fix: keep workbench alive on postgres timeout (#1831) --- internal/cloud/workbench-facts-store.ts | 4 ++++ internal/db/runtime-store.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/cloud/workbench-facts-store.ts b/internal/cloud/workbench-facts-store.ts index 04e5c878..8465c57f 100644 --- a/internal/cloud/workbench-facts-store.ts +++ b/internal/cloud/workbench-facts-store.ts @@ -243,6 +243,10 @@ function otelNonNegativeIntegerOrNull(value) { return Number.isFinite(parsed) && parsed >= 0 ? Math.trunc(parsed) : null; } +function objectValue(value) { + return value && typeof value === "object" && !Array.isArray(value) ? value : {}; +} + async function durableTraceSnapshot(runtimeStore, traceId) { if (!runtimeStore || typeof runtimeStore.queryAgentTraceEvents !== "function") return null; const safeId = safeTraceId(traceId); diff --git a/internal/db/runtime-store.ts b/internal/db/runtime-store.ts index 849d20fe..51d52930 100644 --- a/internal/db/runtime-store.ts +++ b/internal/db/runtime-store.ts @@ -2835,7 +2835,10 @@ export function classifyRuntimeDbError(error) { function isRuntimeDbConnectTimeout(error) { const message = String(error?.message ?? error ?? "").toLowerCase(); - if (!message.includes("timeout exceeded when trying to connect")) return false; + const pgConnectTimeout = message.includes("timeout exceeded when trying to connect"); + const pgConnectionTimeoutTermination = message.includes("connection terminated due to connection timeout"); + if (!pgConnectTimeout && !pgConnectionTimeoutTermination) return false; + if (pgConnectionTimeoutTermination) return true; const stack = String(error?.stack ?? "").toLowerCase(); return !stack || stack.includes("pg-pool") || stack.includes("node_modules/pg"); }