fix: retry unprocessed requests in RequestQueue.add_request#1976
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1976 +/- ##
==========================================
+ Coverage 92.94% 93.02% +0.07%
==========================================
Files 167 167
Lines 11737 11740 +3
==========================================
+ Hits 10909 10921 +12
+ Misses 828 819 -9
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:
|
Pijukatel
approved these changes
Jun 19, 2026
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.
Description
RequestQueue.add_request(singular) made a single best-effortadd_batch_of_requests([request])call and, if the storage client returned the request as unprocessed, just logged a warning and returnedNone— silently dropping the request.add_requests(plural) already retries unprocessed requests via_process_batch, so the two adds had inconsistent durability against best-effort backends (e.g. the Apify platform'sbatch_add_requestsendpoint, which may legitimately return a request as unprocessed).This makes a single add as durable as a batched one:
_process_batchnow returns anAddRequestsResponseaggregating the requests processed across all attempts plus any still unprocessed after the retries are exhausted (it previously returnedNone).add_requestroutes its single request through_process_batchand returnsprocessed_requests[0], returningNoneonly after retries are exhausted.The
ProcessedRequest | Nonereturn contract and the blocking semantics are preserved (for one request,add_requestsalready runs the first batch synchronously), and the retry is safe because adds are idempotent byunique_key.Note: on the failure path
add_requestis now blocking-with-backoff (worst case a few seconds of retry sleeps before returningNone), where it previously returned immediately. That is the intended trade — durability over a fast silent drop.Issues
Testing
test_add_request_retries_unprocessed(a request reported unprocessed on the first attempt is retried and survives) andtest_add_request_returns_none_after_exhausting_retries(stays unprocessed across all attempts → returnsNone, 1 initial + 5 retries). Both fail onmasterand pass with this change.uv run poe lint,uv run poe type-check, and thetests/unit/storages/test_request_queue.pysuite all pass.Checklist