Skip to content

Commit 40ec8ee

Browse files
committed
chore(providers): restore fake timers on a single exit path to satisfy the hook lint
1 parent 7e578a3 commit 40ec8ee

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

apps/sim/providers/openai/core.retry.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,20 @@ describe('OpenAI Responses status retries', () => {
110110
)
111111
}
112112

113-
/** Drives a run to completion under fake timers so backoff costs no wall time. */
113+
/**
114+
* Drives a run to completion under fake timers so backoff costs no wall time.
115+
*
116+
* Timers are restored on a single exit path rather than in a `finally` after a
117+
* `return`: biome reads `vi.useRealTimers` as a React hook and rejects that shape
118+
* as a conditionally-called hook.
119+
*/
114120
async function runWithTimers(fetchMock: unknown, request: Partial<ProviderRequest> = {}) {
115121
vi.useFakeTimers()
116-
try {
117-
const promise = run(fetchMock, request).catch((error: unknown) => error)
118-
await vi.advanceTimersByTimeAsync(120_000)
119-
return await promise
120-
} finally {
121-
vi.useRealTimers()
122-
}
122+
const promise = run(fetchMock, request).catch((error: unknown) => error)
123+
await vi.advanceTimersByTimeAsync(120_000)
124+
const settled = await promise
125+
vi.useRealTimers()
126+
return settled
123127
}
124128

125129
it('retries a 429 and then succeeds', async () => {

0 commit comments

Comments
 (0)