fix: Fall back to drop+recreate when RequestQueue.purge is unsupported#1883
Merged
fix: Fall back to drop+recreate when RequestQueue.purge is unsupported#1883
RequestQueue.purge is unsupported#1883Conversation
Storage clients that cannot purge (e.g. the Apify platform) raise `NotImplementedError`, which broke `BasicCrawler`'s automatic purge on repeated runs. Catch it, log a warning, and drop+reopen the queue so callers keep working.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1883 +/- ##
==========================================
+ Coverage 92.69% 92.70% +0.01%
==========================================
Files 161 161
Lines 11340 11356 +16
==========================================
+ Hits 10512 10528 +16
Misses 828 828
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
janbuchar
reviewed
May 7, 2026
janbuchar
approved these changes
May 7, 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.
Summary
Some storage clients do not support purging the request queue — most notably the Apify platform client, which raises
NotImplementedError. SinceBasicCrawlerstarted callingrequest_manager.purge()automatically on repeated runs (PR #1762), this surfaced as a regression on the Apify platform: a previously working pattern now blew up.RequestQueue.purge()now catchesNotImplementedError, logs a warning, drops the underlying queue, and re-opens it viaRequestQueue.open(), swapping the new client/id into the existing instance so callers likeBasicCrawlerkeep working transparently. This restores the pre-#1762 behavior on the platform (drop the default queue, let the platform recreate it) without exposing the fallback to callers.The new
test_purge_falls_back_to_drop_when_not_implementedcovers the path against all four storage backends (memory, file_system, sql, redis).