From b0880fcafc689fa79598b69f28479aaa027fc263 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Tue, 28 Jul 2026 23:30:54 +0200 Subject: [PATCH] fix: release preview blob URLs --- src/app/components/url-preview/UrlPreviewCard.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/components/url-preview/UrlPreviewCard.tsx b/src/app/components/url-preview/UrlPreviewCard.tsx index 1cce968a8..130253605 100644 --- a/src/app/components/url-preview/UrlPreviewCard.tsx +++ b/src/app/components/url-preview/UrlPreviewCard.tsx @@ -45,7 +45,18 @@ const openMediaInNewTab = async (url: string | undefined) => { } const blob = await downloadMedia(url); const blobUrl = URL.createObjectURL(blob); - window.open(blobUrl, '_blank'); + const child = window.open(blobUrl, '_blank'); + if (!child) { + URL.revokeObjectURL(blobUrl); + return; + } + // Retain the URL until the tab closes since video playback can re-fetch it. + const timer = window.setInterval(() => { + if (child.closed) { + window.clearInterval(timer); + URL.revokeObjectURL(blobUrl); + } + }, 1000); }; function ogPositiveDimension(value: unknown): number | undefined {