Skip to content

fix: keep non-forefront reclaimed requests pending in the single request queue client - #1060

Open
vdusek wants to merge 3 commits into
masterfrom
worktree-fix-b1
Open

fix: keep non-forefront reclaimed requests pending in the single request queue client#1060
vdusek wants to merge 3 commits into
masterfrom
worktree-fix-b1

Conversation

@vdusek

@vdusek vdusek commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

reclaim_request(forefront=False) in the single-mode request queue client discarded the request id from _requests_in_progress and re-cached it, but never re-entered it into _head_requests — the only structure is_empty() and is_finished() read. Once the platform head listing lagged behind the reclaim, both reported the queue finished, AutoscaledPool shut the run down, and the request stayed pending forever while the run reported SUCCEEDED. This is crawlee's ordinary retry path, so any transient request failure near queue exhaustion could silently drop work.

The fix mirrors what add_batch_of_requests already does for non-forefront adds: _head_requests.appendleft(request_id). The forefront=True branch is unchanged. No duplicate risk — _list_head skips ids already in the head, and every crawlee reclaim site operates on a request this client had already popped out of the head.

A regression test, parametrized over forefront, fetches a request through the real path, reclaims it while list_head keeps listing empty, and asserts is_empty()/is_finished() stay False and the request is handed out again. The default case fails without the fix; forefront passed before and after.

Scoped down from the original version of this PR: the shared-client half was made redundant by #1087, and the integration test it added covered the forefront path, which was never broken.

✍️ 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.37%. Comparing base (fcc767a) to head (ba2ae4c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1060      +/-   ##
==========================================
+ Coverage   92.31%   92.37%   +0.06%     
==========================================
  Files          51       51              
  Lines        3317     3318       +1     
==========================================
+ Hits         3062     3065       +3     
+ Misses        255      253       -2     
Flag Coverage Δ
e2e 34.71% <0.00%> (-0.02%) ⬇️
integration 56.57% <100.00%> (+0.01%) ⬆️
unit 88.75% <100.00%> (+1.81%) ⬆️

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 changed the title fix: prevent silent loss of reclaimed requests during queue head propagation fix: keep non-forefront reclaimed requests pending in the single request queue client Aug 21, 2026
@vdusek
vdusek requested a review from Pijukatel August 21, 2026 12:31
@vdusek
vdusek marked this pull request as ready for review August 21, 2026 12:31
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