mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-21 07:45:38 +00:00
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:
@@ -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");
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user