Skip to content

Commit 9b8b371

Browse files
fix: add retry delay when response.ok is false in ensureServerReady
When the health check returns an error status (401, 500, etc.), the loop was immediately continuing to the next attempt without any delay. This caused up to 5 rapid-fire requests in quick succession. The delay was only being applied for the 'upgrading' status case. Now applies the same UPGRADE_RETRY_DELAY_MS delay before retrying when the response is not ok, consistent with the upgrading case. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
1 parent 94006d7 commit 9b8b371

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/relay/src/client.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ export const createRelayClient = (
110110
for (let attempt = 0; attempt < MAX_UPGRADE_RETRIES; attempt++) {
111111
try {
112112
const response = await fetch(healthUrl);
113-
if (!response.ok) continue;
113+
if (!response.ok) {
114+
await new Promise((resolve) =>
115+
setTimeout(resolve, UPGRADE_RETRY_DELAY_MS),
116+
);
117+
continue;
118+
}
114119

115120
const data = (await response.json()) as { status: string };
116121
if (data.status === "upgrading") {

0 commit comments

Comments
 (0)