fix(scrape): cancel queued work and fail closed on budget - #52
Open
gildesmarais wants to merge 4 commits into
Open
fix(scrape): cancel queued work and fail closed on budget#52gildesmarais wants to merge 4 commits into
gildesmarais wants to merge 4 commits into
Conversation
Hold the executor Future and cancel on outer timeout so capacity waits never start Chromium. Remaining helpers may return 0; escalate AUTO→browser only with ≥8s left (unclean skip → challenge_block); soft retries need ≥5s work budget; timeout error strings are phase-honest (queue/boot/work).
Chunk selector waits to ≤2s and run ChallengeDetector between chunks so interstitials fail closed as challenge_block before burning the full wait budget. Boyscout: call_if_available in detector, single unclean surfacing helper, drop dead inspect params.
Map queue/boot/work and challenge_block to capacity vs product signals, and note 504 Future.cancel behavior.
This was referenced Aug 28, 2026
Storage failures are NAVIGATION_ERROR, not timeouts; keep timeout_phase reserved for real timeout outcomes so ops/Sentry tags stay honest.
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.
What changed
Futures when the client budget expires instead of waiting for a hung worker.app/engine/browser_tier.py, detector).timeout_phasestrings in the error envelope / OpenAPI.Why
One hung Chromium or false timeout was cascading: queued work kept running after the client gave up, and operators could not tell queue/boot capacity pain from a slow target site.
Risk
getmay still finish a step after the API has already returned 504; cancel is best-effort on the queue Future.Review map
app/domain/scrape_service.py— Future.cancel / budget fail-closed entry.app/engine/orchestrator.py+app/engine/budget.py— deadline gates and escalate/soft-retry caps.app/engine/browser_tier.py+app/infra/detector.py— mid-wait challenge probe.app/engine/envelope.py/ OpenAPI —timeout_phasecontract.tests/domain/test_scrape_service_cancel.pyand engine challenge/budget specs — behavior locks.Validation
make checkexit 0Adjacent
Rollout: merge scrape-api → release/bump gem → merge web (web uses
respond_to?so pre-bump is safe).