fix(browser-files): return ABORTED instead of a leaked preview lease after a same-turn abort (02-01)

create() checked the signal only before resolving the file, so an abort in
the same turn still produced a lease the caller never released. Each leak
used one of the 16 object URL slots shared with downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-25 23:57:04 +09:00
co-authored by Claude Opus 5.5
parent 4d17259037
commit c9be8d65e4
2 changed files with 68 additions and 0 deletions
@@ -260,6 +260,10 @@ export class BrowserTransientPreview implements TransientPreviewPort {
browserDataFailure("UNAVAILABLE", "PREVIEW"),
);
}
// 02-01. The caller may abort while the file resolves; a lease created
// after that would never be released because the caller drops the result.
const abortedWhileResolving = abortedResult(input.signal, "PREVIEW");
if (abortedWhileResolving) return this.#observe(abortedWhileResolving);
const mediaType = resolved.value.mediaType.trim().toLowerCase();
if (
!EXACT_MEDIA_TYPE.test(mediaType) ||