fix(download): retry the metadata probe; set socket timeouts everywhere - #300
Merged
Conversation
The pre-download metadata probe (duration check) ran outside the retry loop: a transient network blip on that single request failed the whole job immediately, even though the actual download had a 3-attempt backoff. The probe and the download now share one retry policy (_with_retries), with the same retriable/non-retriable classification, cancel translation, and user-visible "retrying" stage message. Every YoutubeDL instance (probe, audio download, video track) now sets an explicit 30 s socket_timeout so a stalled TCP connection can never hang a job indefinitely. Closes #279
6 tasks
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.
Closes #279. Phase 2 of #273 — plan: #273 (comment) (PR-2B).
What
extract_info(download=False)for the duration check) ran outside the retry loop — a transient blip on that one request failed the job instantly while the download itself enjoyed 3-attempt backoff. Both now share one_with_retrieshelper: same retriable/non-retriable lists, backoff schedule,JobCancelledtranslation, and user-visible "Network error — retrying (n/3)…" stage message.YoutubeDLconfigs (probe, audio download, video track) now setsocket_timeout: 30explicitly, so a stalled TCP connection can never hang a job indefinitely.The old inline download retry loop is replaced by the shared helper — behavior-preserving refactor verified by the suite.
Testing
New
tests/test_download_retry.py: transient error retried then succeeds (with stage message asserted), non-retriable ("Private video") raises on attempt 1, exhausted retries re-raise, cancel mid-attempt →JobCancelled, unrecognized errors not retried. Backoff sleeps patched out.Full suite: 185 passed; ruff clean.
🤖 Generated with Claude Code