From bca87d9eebb0bd994a568267f9997e184662b54a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 30 Sep 2026 00:37:51 +0000 Subject: [PATCH] Stabilize the outdated rate-limit cache test The test advanced the clock relative to the real system time while the rate-limit occurrences were recorded against it, so the occurrences could land exactly on the inclusive window start and stay throttled. Freeze the clock and advance strictly past the window instead. Co-Authored-By: Claude Opus 4.8 --- packages/cli-kit/src/private/node/conf-store.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cli-kit/src/private/node/conf-store.test.ts b/packages/cli-kit/src/private/node/conf-store.test.ts index af8d48b9585..d2e251e676f 100644 --- a/packages/cli-kit/src/private/node/conf-store.test.ts +++ b/packages/cli-kit/src/private/node/conf-store.test.ts @@ -13,6 +13,7 @@ import { getCachedPartnerAccountStatus, setCachedPartnerAccountStatus, runWithRateLimit, + timeIntervalToMilliseconds, } from './conf-store.js' import {isLocalEnvironment} from './context/service.js' import {LocalStorage} from '../../public/node/local-storage.js' @@ -548,6 +549,7 @@ describe('runWithRateLimit', () => { test('runs the task as usual when the cache is populated but outdated', async () => { await inTemporaryDirectory(async (cwd) => { // Given + vi.useFakeTimers() const config = new LocalStorage({cwd}) for (let i = 0; i < limit; i++) { // eslint-disable-next-line no-await-in-loop @@ -564,7 +566,8 @@ describe('runWithRateLimit', () => { // When let taskRan = false - vi.setSystemTime(vi.getRealSystemTime() + 1000) + // The rate-limit window is inclusive of its start, so advance strictly past it. + vi.advanceTimersByTime(timeIntervalToMilliseconds(timeout) + 1) const got = await runWithRateLimit( { key,