.Literfieber
.Literfieber
DDeno
Created by .Literfieber on 7/27/2023 in #help
Deno test Leaking resources
Hi i currently try to get used to deno.test but Deno.readTextFile makes the test end in the following error:
error: Leaking resources:
- A file (rid 3) was opened during the test, but not closed during the test. Close the file handle by calling `file.close()`.
error: Leaking resources:
- A file (rid 3) was opened during the test, but not closed during the test. Close the file handle by calling `file.close()`.
My function looks like this:
export async function test() {
try {
const test = await Deno.readTextFile("./test.txt");
return true
}
catch (err) {
log(err);
return false;
}
}
export async function test() {
try {
const test = await Deno.readTextFile("./test.txt");
return true
}
catch (err) {
log(err);
return false;
}
}
Is there a way to close the file so that i don't get the error ?
7 replies
DDeno
Created by .Literfieber on 10/18/2022 in #help
How to transform a Readable Stream to a file.
I have a ReadableStream from a post request and i cant find a way to transform the body(ReadableStream) to a file. I tried to pipe the ReadableStream into a file like this const file = await Deno.open('./test.png', {create: true,write: true,}) myPostRequest.body.pipeTo(file.writable); file.close(); I always get: error: Uncaught (in promise) BadResource: Bad resource ID at async write (deno:ext/net/01_net.js:33:12) at async Object.write (deno:ext/net/01_net.js:82:25) what is the correct way to create a file from a readable stream ?
7 replies