From de13eed72ab823c78e9bdfc862fcf6b28064ff6f Mon Sep 17 00:00:00 2001 From: CloudCLI UI Contributors Date: Mon, 29 Jun 2026 02:25:51 +0000 Subject: [PATCH] fix(file-viewer): revoke blob URL created by an aborted media load If the file switches while the fetch/PDF-validation is awaiting, the effect cleanup runs before objectUrl is assigned, so it revokes nothing and the in-flight load then creates a blob URL that is never freed. Check controller.signal.aborted right after createObjectURL and revoke + bail so rapid switching can't leak object URLs (CodeRabbit: Stability, Major). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../view/subcomponents/CodeEditorMediaPreview.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/code-editor/view/subcomponents/CodeEditorMediaPreview.tsx b/src/components/code-editor/view/subcomponents/CodeEditorMediaPreview.tsx index abb425bb..5c54ff0a 100644 --- a/src/components/code-editor/view/subcomponents/CodeEditorMediaPreview.tsx +++ b/src/components/code-editor/view/subcomponents/CodeEditorMediaPreview.tsx @@ -103,6 +103,16 @@ export default function CodeEditorMediaPreview({ const typed = outType && outType !== blob.type ? new Blob([blob], { type: outType }) : blob; objectUrl = URL.createObjectURL(typed); + + // The cleanup may have already run (deps changed during an await), in + // which case it revoked nothing because objectUrl was still null. Don't + // publish a URL the cleanup will never revoke — drop it ourselves. + if (controller.signal.aborted) { + URL.revokeObjectURL(objectUrl); + objectUrl = null; + return; + } + setUrl(objectUrl); setLoadedKey(sourceKey); } catch (loadError: unknown) {