From 273af797f2e52e80903ebfbe7d4860de375bc181 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:52:05 +0000 Subject: [PATCH] fix(client): keep the base retry delay after a foreground reconnect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the immediate retry path when replacing a stalled connection attempt. Arming a retry timer first would raise the backoff even though the replacement cancels that timer before it fires. Co-authored-by: 김동선 <88572124+dongsun1@users.noreply.github.com> --- packages/client/src/daemon-client.test.ts | 11 +++++++++-- packages/client/src/daemon-client.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/client/src/daemon-client.test.ts b/packages/client/src/daemon-client.test.ts index 9d69c9b067..eba18ed13b 100644 --- a/packages/client/src/daemon-client.test.ts +++ b/packages/client/src/daemon-client.test.ts @@ -2683,13 +2683,15 @@ test("foreground tears down a silently dead socket after two fresh five-second w expect(second.closesFromClient()).toEqual([]); }); -test("foreground replaces a stale connect attempt", async () => { +test("foreground replaces a stale connect attempt and retries at the base delay if it fails", async () => { useHeartbeatClock(); const stalled = new FakeDaemon(); const replacement = new FakeDaemon(); + const healthy = new FakeDaemon(); const { client, attempts } = connectThroughReplacements("foreground-stalled", [ stalled, replacement, + healthy, ]); const connection = client.connect(); void connection.catch(() => undefined); @@ -2700,7 +2702,12 @@ test("foreground replaces a stale connect attempt", async () => { expect(attempts()).toBe(2); expect(stalled.closesFromClient()).toHaveLength(1); - replacement.openConnection(); + replacement.daemonClosesWith("network still waking"); + await vi.advanceTimersByTimeAsync(1_499); + expect(attempts()).toBe(2); + await vi.advanceTimersByTimeAsync(1); + expect(attempts()).toBe(3); + healthy.openConnection(); await connection; expect(client.getConnectionState().status).toBe("connected"); }); diff --git a/packages/client/src/daemon-client.ts b/packages/client/src/daemon-client.ts index d1c6f8e7a0..f3139377b6 100644 --- a/packages/client/src/daemon-client.ts +++ b/packages/client/src/daemon-client.ts @@ -1878,8 +1878,8 @@ export class DaemonClient { reason: "Stale connection attempt", event: "STALE_CONNECT_ON_FOREGROUND", reasonCode: "connect_timeout", + immediate: true, }); - void this.attemptConnect(); } return; }