fix(browser-files): report exhausted object URL leases as retryable (02-04)

Preview and download share one lease registry and download leases stay for a
30 s grace, so running out of slots clears on its own. Only a Blob above the
single-lease ceiling stays LIMIT_EXCEEDED without retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-26 00:08:33 +09:00
co-authored by Claude Opus 5.5
parent c8e4794860
commit 0b41cb38af
5 changed files with 142 additions and 9 deletions
+32
View File
@@ -634,6 +634,38 @@ describe("browser file content policy", () => {
expect(revoked).toEqual([]);
});
it("reports a preview that finds every lease slot in use as retryable (02-04)", async () => {
let urlSequence = 0;
const leases = new ObjectUrlLeaseRegistry(
{
createObjectURL: () => `blob:slot-${urlSequence++}`,
revokeObjectURL() {},
},
{
hardMaxActiveLeases: 1,
hardMaxSingleLeaseBytes: 16,
hardMaxAggregateLeaseBytes: 16,
},
);
const { preview, request } = await verifiedPngPreview(leases);
const held = leases.create(new Blob([new Uint8Array(1)]));
expect(
await preview.create(request(new AbortController().signal)),
).toMatchObject({
ok: false,
error: {
code: "LIMIT_EXCEEDED",
retryable: true,
recovery: "RETRY",
},
});
held.release();
expect(
await preview.create(request(new AbortController().signal)),
).toMatchObject({ ok: true });
});
it("cannot weaken the built-in active-content preview denylist", async () => {
const htmlPolicy = browserFilePolicyReference(
"active-content",