From d47252547bddc01eb2262ce4e60e2ebd918bfc32 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 21 Aug 2026 04:03:23 -0700 Subject: [PATCH] fix: lazy session-states import is best-effort under partial module mocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test harnesses that vi.mock('@/hermes') without setApiRequestProfile make the session-states transitive graph unloadable; the deferred reconcile import then rejected unhandled and failed unrelated suites in shard 2. Catch and skip — the production graph always loads. --- apps/desktop/src/store/gateway.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src/store/gateway.ts b/apps/desktop/src/store/gateway.ts index 9bdac9d0a6..f9b9eb2ca2 100644 --- a/apps/desktop/src/store/gateway.ts +++ b/apps/desktop/src/store/gateway.ts @@ -389,10 +389,13 @@ async function reconnectSecondary(entry: Secondary): Promise { // other sockets is untouched, and a genuinely live turn here re-asserts // busy on its next event. Lazy import: a static edge here closes a module // cycle (session-states → … → gateway) that leaves nanostores atoms - // undefined at init for whichever module loads second. - void import('@/store/session-states').then(({ reconcileBusyStatesOnReconnect }) => - reconcileBusyStatesOnReconnect(entry.scope) - ) + // undefined at init for whichever module loads second. Best-effort catch: + // under partial vi.mock('@/hermes') harnesses the transitive graph can + // fail to load — a skipped reconcile there must not surface as an + // unhandled rejection (the real graph always loads in production). + void import('@/store/session-states') + .then(({ reconcileBusyStatesOnReconnect }) => reconcileBusyStatesOnReconnect(entry.scope)) + .catch(() => undefined) } catch (error) { // The registry no longer knows this connection (removed while we were // backing off), or Electron's deletion guard reports the profile itself