fix: clamp copilot auth refresh overflow (#55360) (thanks @michael-abdo)

This commit is contained in:
Peter Steinberger
2026-03-26 23:42:25 +00:00
parent f0c1057f68
commit 85b169c453
6 changed files with 67 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
import { describe, expect, it } from "vitest";
import { clampRuntimeAuthRefreshDelayMs } from "./runtime-auth-refresh.js";
describe("clampRuntimeAuthRefreshDelayMs", () => {
it("clamps far-future refresh delays to a timer-safe ceiling", () => {
expect(
clampRuntimeAuthRefreshDelayMs({
refreshAt: 12_345_678_901_000,
now: 0,
minDelayMs: 60_000,
}),
).toBe(2_147_483_647);
});
it("still respects the configured minimum delay", () => {
expect(
clampRuntimeAuthRefreshDelayMs({
refreshAt: 1_000,
now: 900,
minDelayMs: 60_000,
}),
).toBe(60_000);
});
});