Skip to content

fix: prevent silent loss of reclaimed requests during queue head propagation#1060

Draft
vdusek wants to merge 4 commits into
masterfrom
worktree-fix-b1
Draft

fix: prevent silent loss of reclaimed requests during queue head propagation#1060
vdusek wants to merge 4 commits into
masterfrom
worktree-fix-b1

Conversation

@vdusek

@vdusek vdusek commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

A request reclaimed with the default forefront=False (crawlee's BasicCrawler retry path) was written only to _requests_cache, which is_empty() and is_finished() never consult — they read the local head estimate. With the request in no head structure, both reported the queue finished while the platform head listing still lagged behind the reclaim. Near queue exhaustion, AutoscaledPool polls is_finished(), gets True from the lagging head, and shuts the run down: the request stays pending in the queue forever while the run reports success.

The fix re-enters the reclaimed id at the back of the local head estimate (_head_requests.appendleft for the single client, _queue_head.append for the shared client), mirroring add_batch_of_requests and the existing forefront=True branch, so the request is retried instead of dropped. The forefront=True paths are unchanged.

Regression tests for both clients reclaim a request while the mocked platform head lags and assert is_empty()/is_finished() stay False — they fail before the fix.

✍️ Drafted by Claude Code

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jul 21, 2026
@vdusek vdusek self-assigned this Jul 21, 2026
@github-actions github-actions Bot added this to the 145th sprint - Tooling team milestone Jul 21, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.00%. Comparing base (58d6da1) to head (0136f4a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1060      +/-   ##
==========================================
+ Coverage   91.89%   92.00%   +0.10%     
==========================================
  Files          51       51              
  Lines        3232     3238       +6     
==========================================
+ Hits         2970     2979       +9     
+ Misses        262      259       -3     
Flag Coverage Δ
e2e ?
integration 57.16% <100.00%> (+0.07%) ⬆️
unit 85.79% <100.00%> (+2.53%) ⬆️

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.

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.

2 participants