Skip to content

Commit 5f33f65

Browse files
B4nanclaude
andauthored
test: fix flaky requestHandlerTimeoutSecs test (#3340)
## Summary - Fix flaky test `should respect the requestHandlerTimeoutSecs option` in `browser_crawler.test.ts` - Use Vitest fake timers with `shouldAdvanceTime: true` to prevent timer leakage - The 1500ms "bad" timer was remaining in the event loop and firing during other concurrent tests ## Test plan - [x] Verified the test passes consistently (ran 5 times in a row) - [x] The fix uses the same fake timer pattern as other tests in the codebase 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9d01334 commit 5f33f65

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

test/core/crawlers/browser_crawler.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ describe('BrowserCrawler', () => {
427427
await localStorageEmulator.init();
428428
const puppeteerPlugin = new PuppeteerPlugin(puppeteer);
429429

430+
vitest.useFakeTimers({ shouldAdvanceTime: true });
430431
try {
431432
const requestList = await RequestList.open({
432433
sources: [{ url: `${serverAddress}/?q=1` }],
@@ -452,6 +453,7 @@ describe('BrowserCrawler', () => {
452453
expect(callSpy).toBeCalledTimes(1);
453454
expect(callSpy).toBeCalledWith('good');
454455
} finally {
456+
vitest.useRealTimers();
455457
await localStorageEmulator.destroy();
456458
}
457459
});

0 commit comments

Comments
 (0)