Repository navigation
test: Deflake throttled-request deferral tests with a stopped throttler clock - #2275
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2275 +/- ##
=======================================
Coverage 93.90% 93.91%
=======================================
Files 182 182
Lines 13144 13144
=======================================
+ Hits 12343 12344 +1
+ Misses 801 800 -1
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
October 5, 2026 14:54
Collaborator
Author
|
@Mantisus could you please try to approve it again? |
Mantisus
approved these changes
Oct 5, 2026
Collaborator
Author
|
amazing, thanks @B4nan |
vdusek
added a commit
that referenced
this pull request
Oct 15, 2026
…clock (#2331) `test_persistent_429_raises_after_stall[retry_on_blocked]` failed on ubuntu / Python 3.10 ([run](https://github.com/apify/crawlee-python/actions/runs/38694178175/job/116286777865)) with `DID NOT RAISE PersistentRateLimitError`. The other 17 legs of the same run passed. The test put the domain into a 50 to 100 ms backoff and let real time pass through a 1.2 s `max_domain_stall`. The crawler defers a 429 only if `is_throttled()` still holds when it handles the error, and on a loaded runner the backoff ran out first. With `max_request_retries=0` the request then took the ordinary-error path, got marked as handled, and the run ended without an error. A 120 ms delay injected into that check reproduces the failure on every run. The throttler now runs on a stopped `Mock` clock with a 1-minute backoff, as in #2275. The clock moves one backoff forward each time the idle crawler asks for a stall reason, and `max_domain_stall` sits between one and two backoffs, so the domain stalls on the check after its second 429. The assertions are unchanged, and the test still fails when `_is_held_back` is forced to `False`. It also finishes in well under a second. The stall tests in the basic crawler suite keep the 50 ms backoff. They run with the default three retries, so a lost race there only spends one of the retries. *✍️ Drafted by Claude Code*
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_static_handler_raised_throttled_error_is_deferredfailed on macOS (run). The test put the domain into a 50 ms backoff and raisedRequestThrottledError. The crawler defers the request only ifis_throttled()still holds when it checks, and on a loaded runner the backoff ran out first. The request then went down the ordinary-error path and fell back to the browser.A new helper,
open_throttler_held_until_reclaim()intests/unit/utils.py, opens the throttler on a stoppedMockclock with a 1-minute backoff. The domain is always still held back when the crawler checks. When the crawler reclaims the deferred request, the clock moves past the backoff, so the retry is dispatched right away.The same race also failed
test_handler_raised_throttled_error_is_deferredin the basic crawler suite (run, on #2274).Six deferral tests in the basic, HTTP, Playwright and adaptive crawler suites now use the helper. Their assertions are unchanged, and all of them fail when
_is_held_backis forced toFalse. The stall tests still use the 50 ms backoff, since they need real time to pass throughmax_domain_stall.Closes #2271
✍️ Drafted by Claude Code