Skip to content

[Bug]: Infinite retry_fresh_session loop when using Cloudflare WARP (YOUTUBE_OUTBOUND_PROXY_URL) and resuming playback (startTimeMs > 0) #397

Closed

Description

@Aquarius-Situla

What happened?

To avoid YouTube's datacenter IP anti-bot blocks (Sign in to confirm you’re not a bot), I configured Cloudflare WARP (caomingjun/warp HTTP/SOCKS auto-proxy) via YOUTUBE_OUTBOUND_PROXY_URL.

While initial playback from timestamp 0 works, resuming a partially watched video after some idle time (startTimeMs > 0, e.g. 1803702) frequently gets stuck in an infinite retry_fresh_session loading loop every ~2–3 seconds without ever recovering playback.

Expected behavior:
When a SABR session encounters a terminal failure during prefetch or resume, retry_fresh_session should either invalidate cached identity/initialization state and successfully recover on the current egress IP, or fail gracefully after a limited number of retries rather than looping indefinitely.

Steps to reproduce

  1. Configure TypeType-Server with YOUTUBE_OUTBOUND_PROXY_URL pointing to a Cloudflare WARP proxy (e.g. caomingjun/warp).
  2. Start watching any long YouTube video and allow it to play to a non-zero timestamp (e.g., ~30 minutes in, startTimeMs=1803702).
  3. Pause or leave the session idle until the session expires or WARP rotates its egress context.
  4. Attempt to resume or reopen the video with startTimeMs > 0.
  5. Observe that the player hangs on loading, while server logs show an endless loop of retry_fresh_session requests every 2–3 seconds.

Area

Backend (API / extraction)

Channel

beta

Anything else?

Root Cause Analysis (WARP Proxy + Session Recovery)

  1. Cloudflare WARP Egress IP Rotation / Dual-Stack (IPv4/IPv6) Drift:

    • Cloudflare WARP is a dual-stack Anycast proxy (104.28.x.x IPv4 and 2a09:bac5:... IPv6). Over time (or between www.youtube.com / youtubei.googleapis.com and rr*.googlevideo.com), WARP's egress IP or address family can shift.
    • Because YouTube binds serverAbrStreamingUrl and SABR session state to the egress IP used during token/player extraction, any egress IP shift or stale session context causes googlevideo.com to reject the SABR media requests during /prefetch, putting the session into state=TERMINAL.
  2. Incomplete Cache Invalidation on retry_fresh_session:

    • When /prefetch fails into state=TERMINAL (~1.2s), SabrPlaybackRecovery returns "recoveryAction": "retry_fresh_session" and calls sessionStore.invalidatePlaybackInfo(videoId).
    • However, when the client immediately retries POST /api/sabr/playback/{videoId}?videoItag=313&audioItag=140&startTimeMs=1803702:
      1. typetype-token reuses its cached identity/PoToken context (poTokenMs=0 innertubeMs=0 on every retry) instead of refreshing the session/identity for the current WARP egress IP.
      2. SabrPlaybackInitializationPreloader hits the cached SabrInitializationData in 0ms (sabr_playback_prepare elapsedMs=0 ready=false), skipping bootstrap validation and immediately jumping to startTimeMs=1803702.
    • As a result, every retry recreates the exact same broken session state and loops indefinitely.

Log Evidence

typetype-server logs:

16:09:22.908 INFO SabrInfoFetcher - sabr_info_fetch videoId=zsFTTKNLcXM startTimeMs=1803702 source=network elapsedMs=125
16:09:22.909 INFO SabrPlaybackStarter - sabr_playback_prepare videoId=zsFTTKNLcXM startTimeMs=1803702 elapsedMs=0 ready=false
16:09:22.911 INFO Application - method=POST path=/sabr/playback/{sessionId} status=202 durationMs=133
16:09:22.974 INFO Application - method=POST path=/sabr/playback/{sessionId} status=200 durationMs=3
16:09:25.160 INFO Application - method=POST path=/sabr/playback/{sessionId} status=202 durationMs=2111
16:09:26.596 INFO SabrInfoFetcher - sabr_info_fetch videoId=zsFTTKNLcXM startTimeMs=1803702 source=network elapsedMs=194
16:09:26.598 INFO SabrPlaybackStarter - sabr_playback_prepare videoId=zsFTTKNLcXM startTimeMs=1803702 elapsedMs=0 ready=false
16:09:28.096 INFO Application - method=POST path=/sabr/playback/{sessionId} status=202 durationMs=1294
...
16:11:42.989 INFO SabrSessionRegistry - sabr_session event=evicted reason=idle videoId=zsFTTKNLcXM ageMs=242993 registrySize=22 liveSessions=0 state=TERMINAL

typetype-token logs (showing cached PoToken/Innertube reuse on every retry):

[sabr-perf] event=youtube_session videoId=zsFTTKNLcXM client=MWEB outcome=ok stage=complete poTokenMs=12 innertubeMs=103 playerMs=71 identityRefreshMs=0 sessionBuildMs=20 totalMs=207
[sabr-perf] event=youtube_session videoId=zsFTTKNLcXM client=MWEB outcome=ok stage=complete poTokenMs=0 innertubeMs=0 playerMs=64 identityRefreshMs=0 sessionBuildMs=15 totalMs=79
[sabr-perf] event=youtube_session videoId=zsFTTKNLcXM client=MWEB outcome=ok stage=complete poTokenMs=0 innertubeMs=0 playerMs=64 identityRefreshMs=0 sessionBuildMs=16 totalMs=80
[sabr-perf] event=youtube_session videoId=zsFTTKNLcXM client=MWEB outcome=ok stage=complete poTokenMs=0 innertubeMs=0 playerMs=74 identityRefreshMs=0 sessionBuildMs=15 totalMs=90

cloudflare-warp proxy logs:

2026/11/10 16:09:22 http.go:308: [http] 172.23.0.7:33066 <-> rr1---sn-oji3b5-5n.googlevideo.com:443
2026/11/10 16:09:24 http.go:310: [http] 172.23.0.7:48894 >-< rr5---sn-oji3b5-58.googlevideo.com:443
2026/11/10 16:09:32 http.go:308: [http] 172.23.0.7:35216 <-> rr4---sn-i3belnl7.googlevideo.com:443

Suggested Fix

  1. When SabrPlaybackRecovery triggers retry_fresh_session after a TERMINAL failure, force an isolated session and identity refresh in typetype-token (rather than reusing cached innertube/poToken state that may be bound to an outdated egress IP) and invalidate cached SabrInitializationData for the failing video/formats.
  2. Ensure consistent IP family / egress routing when YOUTUBE_OUTBOUND_PROXY_URL is used with dual-stack proxies like Cloudflare WARP, and cap consecutive retry_fresh_session attempts to prevent infinite client loops.

Activity

  1. Priveetee commented on Nov 13, 2026

    @Priveetee
    Member

    1.17.0 changes exactly this path: when YouTube puts the session on hold on a resume or a seek, the server now notices on the first answer, replaces the session and checks the new one, instead of retrying with the same one. I tested it behind a gluetun VPN, not behind WARP. Could u update to 1.17.0 and tell me if the loop is still there? If it is, the server and token logs of one failing resume would help me a lot.

  2. Aquarius-Situla commented on Nov 14, 2026

    @Aquarius-Situla
    ContributorAuthor

    Seem like the issue is gone, thx u so much for the fix :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: backendTypeType-Server API or extractionarea: tokenTypeType-Token servicebugSomething isn't workingpriority: mediumMedium priority

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions