From 8ec869c688e726f2d1d54d7bcdeabc340f77fddf Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Sun, 3 Aug 2025 21:05:14 -0600 Subject: [PATCH] add more error handling --- src/components/player/display/base.ts | 29 ++++++ .../player/display/displayInterface.ts | 20 ++++ src/utils/errorDebugInfo.ts | 92 +++++++++++++++++++ 3 files changed, 141 insertions(+) diff --git a/src/components/player/display/base.ts b/src/components/player/display/base.ts index aed413a7..e63c205a 100644 --- a/src/components/player/display/base.ts +++ b/src/components/player/display/base.ts @@ -203,6 +203,33 @@ export function makeVideoElementDisplayInterface(): DisplayInterface { ]; hls?.on(Hls.Events.ERROR, (event, data) => { console.error("HLS error", data); + + // Extract detailed HLS error information + const hlsErrorInfo = { + details: data.details, + fatal: data.fatal, + level: data.level, + levelDetails: (data as any).levelDetails + ? { + url: (data as any).levelDetails.url, + width: (data as any).levelDetails.width, + height: (data as any).levelDetails.height, + bitrate: (data as any).levelDetails.bitrate, + } + : undefined, + frag: data.frag + ? { + url: data.frag.url, + baseurl: data.frag.baseurl, + duration: data.frag.duration, + start: data.frag.start, + sn: data.frag.sn, + } + : undefined, + type: data.type, + url: (data as any).url, + }; + if ( data.fatal && src?.url === data.frag?.baseurl && @@ -213,6 +240,7 @@ export function makeVideoElementDisplayInterface(): DisplayInterface { stackTrace: data.error.stack, errorName: data.error.name, type: "hls", + hls: hlsErrorInfo, }); } else if (data.details === "manifestLoadError") { // Handle manifest load errors specifically @@ -221,6 +249,7 @@ export function makeVideoElementDisplayInterface(): DisplayInterface { stackTrace: data.error?.stack || "", errorName: data.error?.name || "ManifestLoadError", type: "hls", + hls: hlsErrorInfo, }); } }); diff --git a/src/components/player/display/displayInterface.ts b/src/components/player/display/displayInterface.ts index 2f17aaed..1e459b6d 100644 --- a/src/components/player/display/displayInterface.ts +++ b/src/components/player/display/displayInterface.ts @@ -12,6 +12,26 @@ export type DisplayError = { key?: string; errorName: string; type: DisplayErrorType; + hls?: { + details: string; + fatal: boolean; + level?: number; + levelDetails?: { + url: string; + width: number; + height: number; + bitrate: number; + }; + frag?: { + url: string; + baseurl: string; + duration: number; + start: number; + sn: number | string; + }; + type: string; + url?: string; + }; }; export type DisplayInterfaceEvents = { diff --git a/src/utils/errorDebugInfo.ts b/src/utils/errorDebugInfo.ts index 64aee83b..4da876f1 100644 --- a/src/utils/errorDebugInfo.ts +++ b/src/utils/errorDebugInfo.ts @@ -39,6 +39,31 @@ export interface ErrorDebugInfo { downlink?: number; rtt?: number; }; + hls?: { + details: string; + fatal: boolean; + level?: number; + levelDetails?: { + url: string; + width: number; + height: number; + bitrate: number; + }; + frag?: { + url: string; + baseurl: string; + duration: number; + start: number; + sn: number; + }; + type: string; + url?: string; + }; + url: { + pathname: string; + search: string; + hash: string; + }; performance: { memory?: { @@ -115,6 +140,37 @@ export function gatherErrorDebugInfo(error: any): ErrorDebugInfo { downlink: connection?.downlink, rtt: connection?.rtt, }, + hls: error?.hls + ? { + details: error.hls.details, + fatal: error.hls.fatal, + level: error.hls.level, + levelDetails: error.hls.levelDetails + ? { + url: error.hls.levelDetails.url, + width: error.hls.levelDetails.width, + height: error.hls.levelDetails.height, + bitrate: error.hls.levelDetails.bitrate, + } + : undefined, + frag: error.hls.frag + ? { + url: error.hls.frag.url, + baseurl: error.hls.frag.baseurl, + duration: error.hls.frag.duration, + start: error.hls.frag.start, + sn: error.hls.frag.sn, + } + : undefined, + type: error.hls.type, + url: error.hls.url, + } + : undefined, + url: { + pathname: window.location.pathname, + search: window.location.search, + hash: window.location.hash, + }, performance: { memory: memory ? { @@ -181,6 +237,42 @@ export function formatErrorDebugInfo(info: ErrorDebugInfo): string { info.network.downlink ? `Downlink: ${info.network.downlink} Mbps` : "", info.network.rtt ? `RTT: ${info.network.rtt} ms` : "", ``, + `=== URL INFO ===`, + `Path: ${info.url.pathname}`, + info.url.search ? `Query: ${info.url.search}` : "", + info.url.hash ? `Hash: ${info.url.hash}` : "", + ``, + info.hls + ? [ + `=== HLS ERROR DETAILS ===`, + `Details: ${info.hls.details}`, + `Fatal: ${info.hls.fatal}`, + `Type: ${info.hls.type}`, + info.hls.level !== undefined ? `Level: ${info.hls.level}` : "", + info.hls.url ? `URL: ${info.hls.url}` : "", + info.hls.levelDetails + ? [ + `Level Details:`, + ` URL: ${info.hls.levelDetails.url}`, + ` Resolution: ${info.hls.levelDetails.width}x${info.hls.levelDetails.height}`, + ` Bitrate: ${info.hls.levelDetails.bitrate} bps`, + ].join("\n") + : "", + info.hls.frag + ? [ + `Fragment Details:`, + ` URL: ${info.hls.frag.url}`, + ` Base URL: ${info.hls.frag.baseurl}`, + ` Duration: ${info.hls.frag.duration}s`, + ` Start: ${info.hls.frag.start}s`, + ` Sequence: ${info.hls.frag.sn}`, + ].join("\n") + : "", + ] + .filter(Boolean) + .join("\n") + : "", + ``, `=== PERFORMANCE ===`, info.performance.memory ? [