mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix(ext/cache): close resource on error (#16129)
This commit is contained in:
parent
b3444e0d3b
commit
e2990be264
2 changed files with 32 additions and 8 deletions
|
@ -106,7 +106,7 @@ Deno.test(async function cachePutReaderLock() {
|
|||
response,
|
||||
);
|
||||
|
||||
assertRejects(
|
||||
await assertRejects(
|
||||
async () => {
|
||||
await response.arrayBuffer();
|
||||
},
|
||||
|
@ -116,3 +116,25 @@ Deno.test(async function cachePutReaderLock() {
|
|||
|
||||
await promise;
|
||||
});
|
||||
|
||||
Deno.test(async function cachePutResourceLeak() {
|
||||
const cacheName = "cache-v1";
|
||||
const cache = await caches.open(cacheName);
|
||||
|
||||
const stream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.error(new Error("leak"));
|
||||
},
|
||||
});
|
||||
|
||||
await assertRejects(
|
||||
async () => {
|
||||
await cache.put(
|
||||
new Request("https://example.com/"),
|
||||
new Response(stream),
|
||||
);
|
||||
},
|
||||
Error,
|
||||
"leak",
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue