Skip to content

Commit 4def10c

Browse files
committed
changed crawler utils back to original after over-looking simple fix
1 parent 391f8aa commit 4def10c

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

packages/browser-crawler/src/internals/browser-crawler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ export abstract class BrowserCrawler<
578578
},
579579
this.navigationTimeoutMillis,
580580
// This message will never be seen, but is required by addTimeoutToPromise
581-
`Navigation timed out after ${this.navigationTimeoutMillis / 1000} seconds.`,
581+
`Navigation timed out after ${this.navigationTimeoutMillis} ms`,
582582
);
583583
} catch (error) {
584584
// Handle navigation timeout - mark session bad and close page

packages/core/src/crawlers/crawler_utils.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,7 @@ import type { Session } from '../session_pool/session.js';
88
*/
99
export function handleRequestTimeout({ session, errorMessage }: { session?: Session; errorMessage: string }) {
1010
session?.markBad();
11-
12-
// Look for both "ms" and "seconds" patterns
13-
const timeoutMillis = errorMessage.match(/(\d+)\s?ms/)?.[1];
14-
const timeoutSecs = errorMessage.match(/(\d+(?:\.\d+)?)\s?seconds?/)?.[1];
15-
16-
let finalTimeoutSecs: number;
17-
if (timeoutMillis) {
18-
finalTimeoutSecs = Number(timeoutMillis) / 1000;
19-
} else if (timeoutSecs) {
20-
finalTimeoutSecs = Number(timeoutSecs);
21-
} else {
22-
finalTimeoutSecs = 0; // fallback
23-
}
24-
25-
throw new TimeoutError(`Navigation timed out after ${finalTimeoutSecs} seconds.`);
11+
const timeoutMillis = errorMessage.match(/(\d+)\s?ms/)?.[1]; // first capturing group
12+
const timeoutSecs = Number(timeoutMillis) / 1000;
13+
throw new TimeoutError(`Navigation timed out after ${timeoutSecs} seconds.`);
2614
}

0 commit comments

Comments
 (0)