Skip to content

Commit 6f3f4f7

Browse files
committed
fix(dev): stop discord smoke retries past deadline
1 parent acb0e9c commit 6f3f4f7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

scripts/dev/discord-acp-plain-language-smoke.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,14 @@ async function requestDiscordJson<T>(params: {
543543
onTimeout: () => controller.abort(),
544544
})) as { retry_after?: number };
545545
const waitSeconds = typeof body.retry_after === "number" ? body.retry_after : 1;
546-
await sleepImpl(Math.min(Math.ceil(waitSeconds * 1000), remainingTimeoutMs(deadlineMs)));
546+
const waitMs = Math.ceil(waitSeconds * 1000);
547+
const remainingMs = remainingTimeoutMs(deadlineMs);
548+
if (waitMs >= remainingMs) {
549+
throw new Error(
550+
`${params.errorPrefix} ${params.method} ${redactDiscordApiPath(params.path)} exceeded total timeout before retry.`,
551+
);
552+
}
553+
await sleepImpl(waitMs);
547554
continue;
548555
}
549556

0 commit comments

Comments
 (0)