log probing

This commit is contained in:
Simon
2026-06-23 08:09:26 +00:00
parent 785b991d01
commit 80476a8a42

View File

@@ -721,6 +721,7 @@ App.videos = App.videos || {};
const controller = new AbortController(); const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), DIRECT_PROBE_TIMEOUT_MS); const timer = setTimeout(() => controller.abort(), DIRECT_PROBE_TIMEOUT_MS);
let ok = false; let ok = false;
let detail = '';
try { try {
// A simple GET (no custom headers) avoids a CORS preflight. If // A simple GET (no custom headers) avoids a CORS preflight. If
// the response is readable and successful, CORS + reachability // the response is readable and successful, CORS + reachability
@@ -733,14 +734,17 @@ App.videos = App.videos || {};
signal: controller.signal signal: controller.signal
}); });
ok = res.ok || res.status === 206; ok = res.ok || res.status === 206;
detail = `HTTP ${res.status}`;
controller.abort(); controller.abort();
} catch (err) { } catch (err) {
ok = false; ok = false;
detail = (err && err.name === 'AbortError') ? 'timeout' : (err && err.message) || 'fetch failed';
} finally { } finally {
clearTimeout(timer); clearTimeout(timer);
} }
App.videos._directStatus.set(url, ok); App.videos._directStatus.set(url, ok);
directPending.delete(url); directPending.delete(url);
console.log(`[direct-probe] ${ok ? 'DIRECT' : 'PROXY '} (${detail}) ${url}`);
return ok; return ok;
})(); })();
directPending.set(url, promise); directPending.set(url, promise);