test: Deflake adaptive crawler routing tests against request retries - #2198
Open
vdusek wants to merge 2 commits into
Open
test: Deflake adaptive crawler routing tests against request retries#2198vdusek wants to merge 2 commits into
vdusek wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2198 +/- ##
==========================================
+ Coverage 93.61% 93.72% +0.10%
==========================================
Files 181 181
Lines 12825 12825
==========================================
+ Hits 12006 12020 +14
+ Misses 819 805 -14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vdusek
marked this pull request as ready for review
August 27, 2026 10:00
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.
test_adaptive_crawling[Enforced rendering type detection]fails intermittently on Windows CI withassert 4 == 2(example run).When the Playwright sub-crawl stalls and times out,
BasicCrawlerretries the whole request - which is correctbehavior - but the test counts every hook and handler invocation and pulls each rendering type from a shared
cycle(). The retry therefore fires the pre-navigation hook a second time for the same URL and advances the cycle,so the expected
2becomes4.The fix makes the assertions insensitive to retries instead of tolerating them:
test_adaptive_crawlingandtest_adaptive_crawling_parselassert the set of URLs routed to each sub crawlerrather than raw invocation counters.
_SimpleRenderingTypePredictormemoizes its prediction per URL, so a retried request keeps the rendering type itwas first assigned.
Verified with deterministic fault injection - patching
PlaywrightCrawler._navigateto fail the first navigationper URL, which runs after the pre-navigation hooks and so reproduces the CI sequence exactly. Before the change 4
of the 5 affected cases fail, including the exact
assert 4 == 2; after it all pass, plus 0/100 failures under arepeated parallel run.
No production code is touched, and the routing property under test is unchanged: wrong routing, a missing
pre-navigation hook, or a URL reaching both sub crawlers all still fail.
✍️ Drafted by Claude Code