fix(github-copilot): preserve cumulative poll backoff (#103434)

This commit is contained in:
Peter Steinberger
2026-08-09 04:50:18 -07:00
committed by GitHub
parent 71a33f07a9
commit 2a57e1a1af
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -370,7 +370,7 @@ describe("runGitHubCopilotDeviceFlow — polling intervals", () => {
const pollTimes: number[] = [];
const pollResponses = [
{ error: "authorization_pending" },
{ error: "slow_down" },
{ error: "slow_down", interval: 7 },
{ error: "slow_down" },
{ access_token: "test-access-token", token_type: "bearer" },
];
+5 -3
View File
@@ -222,9 +222,11 @@ async function pollForAccessToken(params: {
continue;
}
if (err === "slow_down") {
intervalMs =
positiveSecondsToSafeMilliseconds(json.interval) ??
Math.min(Number.MAX_SAFE_INTEGER, intervalMs + GITHUB_DEVICE_FLOW_SLOW_DOWN_INCREMENT_MS);
// slow_down is cumulative; a returned interval may raise but never lower the required floor.
intervalMs = Math.max(
Math.min(Number.MAX_SAFE_INTEGER, intervalMs + GITHUB_DEVICE_FLOW_SLOW_DOWN_INCREMENT_MS),
positiveSecondsToSafeMilliseconds(json.interval) ?? 0,
);
continue;
}
if (err === "expired_token") {