Repository navigation
fix: keep a crawler's default statistics off a standalone Statistics' persist key - #4299
Merged
Merged
Conversation
vladfrangu
approved these changes
Nov 8, 2026
janbuchar
self-requested a review
November 9, 2026 09:15
janbuchar
requested changes
Nov 9, 2026
janbuchar
left a comment
Contributor
There was a problem hiding this comment.
Side effect: an anonymous crawler created after one with an explicit id now persists to _0 instead of _1, as in 3.x.
This should be (very briefly) mentioned in the upgrading guide
…ollision # Conflicts: # packages/basic-crawler/src/internals/basic-crawler.ts
Contributor
|
The fix itself has been merged as part of #4487 |
…ollision # Conflicts: # docs/upgrading/upgrading-v4/upgrading-v4.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A crawler without an explicit id gave its default Statistics the crawler's instance index as its id. A Statistics created without an id takes its number from a separate counter, and the crawler's default never advanced that counter. So a crawler and a standalone Statistics could end up with the same number and overwrite each other under the same CRAWLEE_CRAWLER_STATISTICS_{id} key, whichever of them was created first.
The crawler now passes its id to the default Statistics only when one was set. Otherwise the default takes the next number from the counter, like any other Statistics without an id, which is how 3.x numbered them. The first crawler still persists to CRAWLEE_CRAWLER_STATISTICS_0 unless a Statistics was created before it, and a crawler with an explicit id still persists under that id.
I didn't use the fix proposed in the issue (advancing the counter on every construction). It only covers a Statistics created after the crawler: one created before the first crawler would still take 0, the number the crawler uses too.
Side effect: an anonymous crawler created after one with an explicit id now persists to _0 instead of _1, as in 3.x.
Closes #4295