Repository navigation
Description
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
- Configure
TypeType-ServerwithYOUTUBE_OUTBOUND_PROXY_URLpointing to a Cloudflare WARP proxy (e.g.caomingjun/warp). - Start watching any long YouTube video and allow it to play to a non-zero timestamp (e.g., ~30 minutes in,
startTimeMs=1803702). - Pause or leave the session idle until the session expires or WARP rotates its egress context.
- Attempt to resume or reopen the video with
startTimeMs > 0. - Observe that the player hangs on loading, while server logs show an endless loop of
retry_fresh_sessionrequests every 2–3 seconds.
Area
Backend (API / extraction)
Channel
beta
Anything else?
Root Cause Analysis (WARP Proxy + Session Recovery)
-
Cloudflare WARP Egress IP Rotation / Dual-Stack (IPv4/IPv6) Drift:
- Cloudflare WARP is a dual-stack Anycast proxy (
104.28.x.xIPv4 and2a09:bac5:...IPv6). Over time (or betweenwww.youtube.com/youtubei.googleapis.comandrr*.googlevideo.com), WARP's egress IP or address family can shift. - Because YouTube binds
serverAbrStreamingUrland SABR session state to the egress IP used during token/player extraction, any egress IP shift or stale session context causesgooglevideo.comto reject the SABR media requests during/prefetch, putting the session intostate=TERMINAL.
- Cloudflare WARP is a dual-stack Anycast proxy (
-
Incomplete Cache Invalidation on
retry_fresh_session:- When
/prefetchfails intostate=TERMINAL(~1.2s),SabrPlaybackRecoveryreturns"recoveryAction": "retry_fresh_session"and callssessionStore.invalidatePlaybackInfo(videoId). - However, when the client immediately retries
POST /api/sabr/playback/{videoId}?videoItag=313&audioItag=140&startTimeMs=1803702:typetype-tokenreuses its cached identity/PoToken context (poTokenMs=0 innertubeMs=0on every retry) instead of refreshing the session/identity for the current WARP egress IP.SabrPlaybackInitializationPreloaderhits the cachedSabrInitializationDatain0ms(sabr_playback_prepare elapsedMs=0 ready=false), skipping bootstrap validation and immediately jumping tostartTimeMs=1803702.
- As a result, every retry recreates the exact same broken session state and loops indefinitely.
- When
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
- When
SabrPlaybackRecoverytriggersretry_fresh_sessionafter aTERMINALfailure, force an isolated session and identity refresh intypetype-token(rather than reusing cachedinnertube/poTokenstate that may be bound to an outdated egress IP) and invalidate cachedSabrInitializationDatafor the failing video/formats. - Ensure consistent IP family / egress routing when
YOUTUBE_OUTBOUND_PROXY_URLis used with dual-stack proxies like Cloudflare WARP, and cap consecutiveretry_fresh_sessionattempts to prevent infinite client loops.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
Priveetee commentedon Nov 13, 2026
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.
Aquarius-Situla commentedon Nov 14, 2026
Seem like the issue is gone, thx u so much for the fix :D