mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-07-02 10:33:00 +08:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user