Skip to content

Commit ebc89d2

Browse files
committed
fix: support reloading of sessions with lots of retries
When the existing session has very large retry histogram, we failed with `RangeError: Maximum call stack size exceeded` because of doing `a.push(...b)`.
1 parent 45bbd8d commit ebc89d2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/core/src/crawlers/statistics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ export class Statistics {
305305

306306
this.log.debug('Recreating state from KeyValueStore', { persistStateKey: this.persistStateKey });
307307

308-
this.requestRetryHistogram.push(...savedState.requestRetryHistogram);
308+
// the `requestRetryHistogram` array might be very large, we could end up with
309+
// `RangeError: Maximum call stack size exceeded` if we use `a.push(...b)`
310+
savedState.requestRetryHistogram.forEach((idx) => this.requestRetryHistogram.push(idx));
309311
this.state.requestsFinished = savedState.requestsFinished;
310312
this.state.requestsFailed = savedState.requestsFailed;
311313
this.state.requestsRetries = savedState.requestsRetries;

0 commit comments

Comments
 (0)