From 8f519b02519922368c0708937a3ce08290d03935 Mon Sep 17 00:00:00 2001 From: Josue Zamudio Date: Sun, 30 Aug 2026 19:25:49 +0000 Subject: [PATCH] hls.js: outlast CDN segment stalls (TTFT 5s->15s, 8 retries) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The upstream CDN intermittently serves 0 bytes on segments for 10s+ (fragLoadTimeOut errors 17:58-18:14 and 19:16-19:18 today). hls.js's default 5s time-to-first-byte abort dropped the XHR before the proxy's 12s upstream attempt + 300ms retry could answer with its 502, so the proxy-side retry never got a chance and stalls went straight to fatal. fragLoadPolicy: maxTimeToFirstByteMs 15000 (> proxy's 12s timeout), maxNumRetry 8 — slow-but-alive segments now finish, and stall tolerance rises to several minutes. --- static/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/static/app.js b/static/app.js index 18ce665..9c2b47e 100644 --- a/static/app.js +++ b/static/app.js @@ -696,7 +696,12 @@ async function play(ep_id, ep_no) { document.getElementById("player").replaceChildren(v); playerOverlay("Loading\u2026"); if (!window.Hls || !Hls.isSupported()) throw new Error("HLS not supported in this browser"); - hls = new Hls(); + // the upstream CDN occasionally stalls on segment bytes (0 bytes for + // 10s+). hls.js's default 5s time-to-first-byte abort would drop the XHR + // before our proxy's 12s upstream attempt (+300ms retry) can answer with + // its 502 — keep TTFT past the proxy timeout so slow-but-alive segments + // finish, and the proxy's retry path gets a chance + hls = new Hls({ fragLoadPolicy: { default: { maxTimeToFirstByteMs: 15000, maxNumRetry: 8 } } }); hls.on(Hls.Events.ERROR, (_, data) => { if (data.fatal) { stopHls();