Skip to content

fix: survive stalled requests during batch fetches - #82

Merged
nrvim merged 1 commit into
mainfrom
fix/fetch-batch-resilience
Aug 22, 2026
Merged

fix: survive stalled requests during batch fetches#82
nrvim merged 1 commit into
mainfrom
fix/fetch-batch-resilience

Conversation

@nrvim

@nrvim nrvim commented Aug 22, 2026

Copy link
Copy Markdown
Owner

A full 10-year sync died in year 2 with selenium.common.exceptions.TimeoutException: Message: script timeout propagating out of fetch_all_fetch_batch. Root cause: the in-page JS awaits all endpoint fetches with no per-request timeout, so one stalled fetch() hangs the async script until Selenium's 120s script timeout kills it — and no call site catches the exception, so the whole sync crashes.

Two layers of defense:

  • Per-request timeout in the page: every fetch() (REST and GraphQL) now carries AbortSignal.timeout(60000). A stalled request now resolves as a per-endpoint error — already tolerated by all callers — instead of hanging the script.
  • Batch-level retry: _fetch_batch retries up to 3× on WebDriverException (10s apart), then prints a loud warning and skips the batch so a long sync keeps going; the sync is upsert-based, so a re-run fills any skipped gap.

Tests (watched fail first): retry-then-succeed, persistent-failure-returns-empty, and a guard that the in-page fetches keep their AbortSignal timeout. Full suite: 254 passed, ruff clean.

🤖 Generated with Claude Code

A single stalled fetch() inside _fetch_batch's execute_async_script hung
the whole script until Selenium's 120s script timeout fired, and the
TimeoutException propagated uncaught out of fetch_all — killing a
multi-year full sync partway through (observed in year 2 of 10).

Two layers of defense:
- Every in-page fetch now carries AbortSignal.timeout(60s), so a stalled
  request degrades to one skipped endpoint instead of hanging the script.
- _fetch_batch retries the batch up to 3 times on WebDriverException,
  then loudly skips it so the sync continues; a re-run fills the gap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nrvim
nrvim merged commit ee7dd95 into main Aug 22, 2026
7 checks passed
@nrvim
nrvim deleted the fix/fetch-batch-resilience branch August 22, 2026 18:40
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.

1 participant