I suspect the following to be a bug, if not, please enlighten me on how to do this right, thanks 🙂
deno version: 1.30.3 (release, x86_64-unknown-linux-gnu)
Deno.test({
name: "Deno.readTextFile with AbortSignal (not aborted)",
async fn() {
const path = "readTextFile.txt";
const data = "Hey there";
await Deno.writeTextFile(path, data, { append: false, create: true });
const ac = new AbortController();
const content = await Deno.readTextFile(path, { signal: ac.signal });
ac.abort();
},
});
Deno.test({
name: "Deno.readTextFile with AbortSignal (aborted afterwards)",
async fn() {
const path = "readTextFile.txt";
const data = "Hey there";
await Deno.writeTextFile(path, data, { append: false, create: true });
const ac = new AbortController();
const content = await Deno.readTextFile(path, { signal: ac.signal });
ac.abort();
},
});
This results in:
Deno.readTextFile with AbortSignal (not aborted) ... FAILED (5ms)
error: AssertionError: Test case is leaking 1 resource:
- A "cancellation" resource (rid 9) was created during the test, but not cleaned up during the test. Close the resource before the end of the test.
Deno.readTextFile with AbortSignal (aborted afterwards) ... FAILED (4ms)
error: AssertionError: Test case is leaking 1 resource:
- A "cancellation" resource (rid 6) was created during the test, but not cleaned up during the test. Close the resource before the end of the test.