Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

fix: support reloading of sessions with lots of retries

Martin Adámekebc89d2d69d5
diff --git a/packages/core/src/crawlers/statistics.ts b/packages/core/src/crawlers/statistics.ts
index 5be9ec09e..44ada6d59 100644
--- a/packages/core/src/crawlers/statistics.ts
+++ b/packages/core/src/crawlers/statistics.ts
@@ -305,7 +305,9 @@ export class Statistics {
this.log.debug('Recreating state from KeyValueStore', { persistStateKey: this.persistStateKey });
- this.requestRetryHistogram.push(...savedState.requestRetryHistogram);
+ // the `requestRetryHistogram` array might be very large, we could end up with
+ // `RangeError: Maximum call stack size exceeded` if we use `a.push(...b)`
+ savedState.requestRetryHistogram.forEach((idx) => this.requestRetryHistogram.push(idx));
this.state.requestsFinished = savedState.requestsFinished;
this.state.requestsFailed = savedState.requestsFailed;
this.state.requestsRetries = savedState.requestsRetries;