fix(subtitles): retry incomplete youtube fast-path fetches#1320
fix(subtitles): retry incomplete youtube fast-path fetches#1320frogGuaGuaGuaGua wants to merge 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 98db981 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor trust score42/100 — Moderate This score estimates contributor familiarity with Outcome
Score breakdown
Signals used
Policy
Updated automatically when the PR changes or when a maintainer reruns the workflow. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98db9811e6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| event.segs?.some(seg => seg.utf8.trim().length > 0), | ||
| ).length | ||
|
|
||
| return textEventCount <= 1 |
There was a problem hiding this comment.
Don’t force fallback on valid single-cue subtitles
This fallback condition treats any fast-path response with one text event as incomplete when playerState < 1, but single-cue captions are valid for short videos. In that case fetch() now always enters the slow fallback path and waits through waitForPlayerState retries before refetching, which introduces avoidable latency (and extra failure surface) even though the fast-path data is already complete.
Useful? React with 👍 / 👎.
Summary
Why
On issue #1319, the reporter could still get
timedtext200 responses, but some videos showed loading forever, no subtitles, or only the first translated line. The current fetcher only retried when the fast path threw/returned null, so an unready-but-200 timedtext response could be accepted as final.Fixes #1319
Validation
SKIP_FREE_API=true pnpm vitest run src/utils/subtitles/__tests__/youtube-fetcher.test.tspnpm eslint src/utils/subtitles/fetchers/youtube/index.ts src/utils/subtitles/__tests__/youtube-fetcher.test.tspnpm tsc --noEmitgit pushpre-push checks:nx run @read-frog/extension:lint,nx run @read-frog/extension:type-check,nx run @read-frog/extension:testSummary by cubic
Fallback to the POT/player-state path when YouTube’s fast
timedtextreturns empty or only the first line before the player is ready, preventing stalled or partial subtitles. Fixes #1319.playerStatein fast fetch and gate fallback viashouldFallbackFromFastPath.Written for commit 98db981. Summary will update on new commits.