From d2b68cd0e6f947387a925ac0101a5859eb5cbd67 Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Sun, 31 May 2026 22:05:36 -0400 Subject: [PATCH] fix(desktop): log window-open failures after backend readiness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bugbot (low): the pool's onReady absorbed handleBackendReady failures with Effect.catch(() => Effect.void), and the comment claimed the window service logs them. It doesn't — createWindow/createMain/createMainIfBackendReady only log on success, so a post-readiness window-open failure vanished silently and was near-impossible to diagnose in production. Log the error via a new desktop-backend-pool component logger before swallowing it (we still must not let it block the readiness callback, which would prevent restartAttempt from being reset). Corrected the comment. --- .../desktop/src/backend/DesktopBackendPool.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/backend/DesktopBackendPool.ts b/apps/desktop/src/backend/DesktopBackendPool.ts index be961b7ca2..0133ad9ccf 100644 --- a/apps/desktop/src/backend/DesktopBackendPool.ts +++ b/apps/desktop/src/backend/DesktopBackendPool.ts @@ -98,6 +98,9 @@ import * as DesktopBackendManager from "./DesktopBackendManager.ts"; import * as DesktopObservability from "../app/DesktopObservability.ts"; import * as DesktopWindow from "../window/DesktopWindow.ts"; +const { logWarning: logBackendPoolWarning } = + DesktopObservability.makeComponentLogger("desktop-backend-pool"); + export type BackendInstanceId = DesktopBackendManager.BackendInstanceId; export const BackendInstanceId = DesktopBackendManager.BackendInstanceId; export const PRIMARY_INSTANCE_ID = DesktopBackendManager.PRIMARY_INSTANCE_ID; @@ -220,12 +223,20 @@ export const layer = Layer.effect( id: DesktopBackendManager.PRIMARY_INSTANCE_ID, label: primaryLabel, configResolve: configuration.resolvePrimary, - // Window creation errors propagating out of handleBackendReady are - // swallowed here on purpose: they're logged by the window service - // and we don't want a stuck splash window to block the readiness - // callback (which would prevent restartAttempt from being reset). + // Window creation errors propagating out of handleBackendReady must + // not block the readiness callback (that would prevent restartAttempt + // from being reset), so we absorb them here. The window service only + // logs on success, so log the failure here before swallowing it — + // otherwise a post-readiness window-open failure vanishes silently and + // is near-impossible to diagnose in production. onReady: (httpBaseUrl) => - desktopWindow.handleBackendReady(httpBaseUrl).pipe(Effect.catch(() => Effect.void)), + desktopWindow.handleBackendReady(httpBaseUrl).pipe( + Effect.catch((error) => + logBackendPoolWarning("failed to open main window after backend readiness", { + error: error.message, + }), + ), + ), onShutdown: () => desktopWindow.handleBackendNotReady, });