Skip to content

fix: propagate autoscaled pool scheduling errors - #2229

Merged
vdusek merged 6 commits into
apify:masterfrom
Kuang-xianxin:fix/propagate-orchestrator-errors
Sep 16, 2026
Merged

vdusek merged 6 commits into
apify:masterfrom
Kuang-xianxin:fix/propagate-orchestrator-errors

Conversation

@Kuang-xianxin

Copy link
Copy Markdown
Contributor

Description

When a request manager's is_empty() or is_finished() raises, BasicCrawler.run() currently logs the orchestrator error but returns normally with final statistics. A failed queue status check can therefore look like a successfully completed crawl while requests remain pending.

Retain scheduling exceptions until the existing worker cleanup finishes, then fail the pool's result future instead of resolving it successfully. Preserve a result already set by a worker failure or abort. The regression tests exercise the crawler with a real filesystem queue, inject errors only at its status methods, and verify that a new crawler can process the pending request after recovery. A separate event-controlled test checks that an active worker finishes before the scheduling error reaches the caller.

Issues

Found during source review; no existing issue linked. This concerns scheduling callbacks, distinct from the worker-task timeout handling in #2009.

Testing

  • Five new regression cases fail on unmodified 0853d79e670cba27f9692919688305d1cc565c6c because no exception reaches the caller.
  • Python 3.10.20: all five regression cases pass.
  • Python 3.13.14: pytest tests/unit/_autoscaling tests/unit/crawlers/_basic tests/unit/_utils/test_recurring_task.py -k 'not test_send_request_works' passes 157 tests, with 1 skipped and 2 deselected.
  • Full Ruff lint and formatting checks pass (599 files); full ty check --python-platform linux and changed-file native Windows typing pass.
  • Native Windows full typing reports two BaseContext.Process diagnostics in unchanged test_system.py; the same diagnostics occur on the unmodified base. The two existing test_send_request_works cases fail with JSON decoding errors against the local test server on both the patch and the unmodified base; they are excluded from the final related-suite run. The full repository/browser/service matrix was not run locally.

Checklist

  • CI passed

@vdusek vdusek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @Pijukatel please take a look as well.

@vdusek
vdusek requested a review from Pijukatel September 16, 2026 10:47
@vdusek
vdusek merged commit cb7822e into apify:master Sep 16, 2026
66 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants