Skip to content

test: deflake the persistent 429 stall test with a stopped throttler clock - #2331

Merged
vdusek merged 1 commit into
masterfrom
test/deflake-persistent-429-stall
Oct 15, 2026
Merged

vdusek merged 1 commit into
masterfrom
test/deflake-persistent-429-stall

Conversation

@vdusek

@vdusek vdusek commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

test_persistent_429_raises_after_stall[retry_on_blocked] failed on ubuntu / Python 3.10 (run) 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

@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels Oct 15, 2026
@vdusek vdusek self-assigned this Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.04%. Comparing base (680c7ef) to head (85cc2d7).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2331      +/-   ##
==========================================
- Coverage   94.15%   94.04%   -0.11%     
==========================================
  Files         184      184              
  Lines       13644    13644              
==========================================
- Hits        12846    12832      -14     
- Misses        798      812      +14     
Flag Coverage Δ
unit 94.04% <ø> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek
vdusek requested a review from Mantisus October 15, 2026 08:27
@vdusek
vdusek marked this pull request as ready for review October 15, 2026 08:27
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Oct 15, 2026
@vdusek
vdusek requested a review from apify-factory October 15, 2026 09:11

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@apify-approval-mirror apify-approval-mirror Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mirroring approval from @Mantisus.

@vdusek
vdusek merged commit 508f544 into master Oct 15, 2026
43 of 47 checks passed
@vdusek
vdusek deleted the test/deflake-persistent-429-stall branch October 15, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants