Skip to content

fix: Fall back to drop+recreate when RequestQueue.purge is unsupported#1883

Merged
vdusek merged 2 commits intomasterfrom
fix/request-queue-purge-fallback
May 7, 2026
Merged

fix: Fall back to drop+recreate when RequestQueue.purge is unsupported#1883
vdusek merged 2 commits intomasterfrom
fix/request-queue-purge-fallback

Conversation

@vdusek
Copy link
Copy Markdown
Collaborator

@vdusek vdusek commented May 7, 2026

Summary

Some storage clients do not support purging the request queue — most notably the Apify platform client, which raises NotImplementedError. Since BasicCrawler started calling request_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 catches NotImplementedError, logs a warning, drops the underlying queue, and re-opens it via RequestQueue.open(), swapping the new client/id into the existing instance so callers like BasicCrawler keep 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_implemented covers the path against all four storage backends (memory, file_system, sql, redis).

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.
@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels May 7, 2026
@vdusek vdusek self-assigned this May 7, 2026
@vdusek vdusek requested a review from janbuchar May 7, 2026 13:16
@github-actions github-actions Bot added this to the 140th sprint - Tooling team milestone May 7, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label May 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.70%. Comparing base (b912177) to head (9278cac).
⚠️ Report is 3 commits behind head on master.

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              
Flag Coverage Δ
unit 92.70% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread src/crawlee/storages/_request_queue.py Outdated
@vdusek vdusek requested a review from janbuchar May 7, 2026 14:32
@vdusek vdusek merged commit cd15dce into master May 7, 2026
32 checks passed
@vdusek vdusek deleted the fix/request-queue-purge-fallback branch May 7, 2026 19:11
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.

3 participants