From f97fb957dc243563da070a3b7bd70be8ef714f0b Mon Sep 17 00:00:00 2001 From: Alix von Schirp Date: Sun, 22 Feb 2026 18:23:29 +0100 Subject: [PATCH] fix?: undefined tags Signed-off-by: Alix von Schirp --- ffprobe-wasm-app | 2 +- src/worker.mts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ffprobe-wasm-app b/ffprobe-wasm-app index 54b90ac..62ae9d0 160000 --- a/ffprobe-wasm-app +++ b/ffprobe-wasm-app @@ -1 +1 @@ -Subproject commit 54b90ac7f51b5c3ef4e6f8316f58b42beb52535d +Subproject commit 62ae9d08f01c948ea771d10509bcef7d305f6aa9 diff --git a/src/worker.mts b/src/worker.mts index 6d4715e..00504b5 100644 --- a/src/worker.mts +++ b/src/worker.mts @@ -92,7 +92,7 @@ export function createListener( function serializeStreams(streams: Vector>) { return vectorToArray(streams).map((stream) => ({ ...stream, - tags: dictionaryVectorToRecord(stream.tags), + tags: (stream && stream.tags) ? dictionaryVectorToRecord(stream.tags) : {}, })); } @@ -109,16 +109,19 @@ export function createListener( const rawInfo = get_file_info(`/work/${fileName}`); + // Safety check on rawInfo itself + if (!rawInfo) throw new Error("FFprobe failed to return file info"); + return { streams: serializeStreams(rawInfo.streams), - chapters: vectorToArray(rawInfo.chapters).map((chapter) => ({ + chapters: rawInfo.chapters ? vectorToArray(rawInfo.chapters).map((chapter) => ({ ...chapter, - tags: dictionaryVectorToRecord(chapter.tags), - })), + tags: chapter.tags ? dictionaryVectorToRecord(chapter.tags) : {}, + })) : [], format: { ...rawInfo.format, - tags: dictionaryVectorToRecord(rawInfo.format.tags), - }, + tags: (rawInfo.format && rawInfo.format.tags) ? dictionaryVectorToRecord(rawInfo.format.tags) : {}, + } }; } finally { // Cleanup mount.