Fix YouTube API rate limiting in large playlist imports#1322
Open
renaude wants to merge 4 commits into
Open
Conversation
Large playlist imports previously fired one getVideosByID HTTP call per 50-item page with no concurrency limit (100 simultaneous requests for a 5000-item playlist), routinely exhausting YouTube quota and sockets. - Cap concurrent getVideosByID calls at 3 via p-limit in getPlaylist - Add got-level retry (3 attempts) with exponential backoff (1s/2s/4s) and Retry-After header support, covering search(), getVideo(), and getPlaylist() uniformly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use got's RetryObject type for calculateDelay (attemptCount + retryAfter) - Parenthesise exponentiation to satisfy no-mixed-operators - Restore single quotes and style to pass eslint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📦 🤖 A new release has been made for this pull request.To play around with this PR, pull Images are available for x86_64 and ARM64.
|
Contributor
|
Autoreview found one real blocker in Light fix: either remove the custom Local lint, typecheck, test, and build passed, but I would not approve until this retry behavior is fixed. |
- Return 0 when computedValue === 0 (got signals no retry) - Drop the * 1000 on retryAfter — got already passes it in milliseconds Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Problem
When importing a large YouTube playlist,
getPlaylistfires onegetVideosByIDHTTP call per 50-item page with no concurrency limit. A 5000-item playlist results in 100 simultaneous YouTube Data API requests, which:Changes
src/services/youtube-api.tsgetVideosByIDcall inpLimit(3)so at most 3 video-detail fetches run concurrently regardless of playlist length (p-limitis already a project dependency)retryconfig to thegotinstance (3 attempts, exponential backoff 1s/2s/4s, honouringRetry-Afterheader) — this coverssearch(),getVideo(), andgetPlaylist()uniformly so transient 429/5xx errors recover automaticallyTest plan
🤖 Generated with Claude Code