Skip to content

fix: correct reclaim_request counter adjustment in Apify request queue clients#973

Draft
vdusek wants to merge 4 commits into
masterfrom
fix/single-rq-client-returns-handled-requests
Draft

fix: correct reclaim_request counter adjustment in Apify request queue clients#973
vdusek wants to merge 4 commits into
masterfrom
fix/single-rq-client-returns-handled-requests

Conversation

@vdusek

@vdusek vdusek commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix handled-request bookkeeping in the Apify request queue clients.

reclaim_request counter adjustment was dead code (both clients)

When reclaiming a previously handled request, the metadata counters (handled_request_count / pending_request_count) were never adjusted, so they drifted.

Root cause: The guard if request.was_already_handled and ... read was_already_handled (a computed property equal to handled_at is not None) after request.handled_at had just been set to None, so it was always False.

Fix: Capture was_already_handled before clearing handled_at, then use the captured value in the counter-adjustment condition. Applied to both the single and shared clients. Includes a regression test parametrized over both clients.

@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 Jun 12, 2026
@vdusek vdusek self-assigned this Jun 12, 2026
@github-actions github-actions Bot added this to the 142nd sprint - Tooling team milestone Jun 12, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.10%. Comparing base (0daca28) to head (04b0339).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #973      +/-   ##
==========================================
+ Coverage   89.90%   90.10%   +0.20%     
==========================================
  Files          49       49              
  Lines        3091     3093       +2     
==========================================
+ Hits         2779     2787       +8     
+ Misses        312      306       -6     
Flag Coverage Δ
e2e 35.88% <0.00%> (-0.03%) ⬇️
integration 56.90% <100.00%> (+0.02%) ⬆️
unit 80.50% <100.00%> (+1.75%) ⬆️

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: skip already-handled requests in single RQ client's fetch_next_request fix: correct handled-request handling in Apify request queue clients Jun 12, 2026
vdusek added 2 commits June 12, 2026 18:28
…t-returns-handled-requests

# Conflicts:
#	tests/unit/storage_clients/test_apify_request_queue_client.py
@vdusek vdusek changed the title fix: correct handled-request handling in Apify request queue clients fix: correct reclaim_request counter adjustment in Apify request queue clients Jun 12, 2026
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