fix(client): keep the base retry delay after a foreground reconnect

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>
This commit is contained in:
paseo-bot[bot]
2026-11-20 20:52:05 +00:00
co-authored by 김동선
parent e0009dfbad
commit 273af797f2
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -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");
});
+1 -1
View File
@@ -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;
}