D
Deno

help

Deno test Leaking resources

L.literfieber7/27/2023
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 ?
IioB7/27/2023
could you share the actual test code you're using, it doesn't look like there's an error in this
L.literfieber7/27/2023
Deno.test(async function t() {
const res = await collection.test()
assertEquals(res, true)
}
)
Deno.test(async function t() {
const res = await collection.test()
assertEquals(res, true)
}
)
IioB7/27/2023
I cannot reproduce this on my end this is the code I'm using (derived from yours):
import { assertEquals } from "https://deno.land/std@0.196.0/assert/assert_equals.ts"

export async function test() {
try {
const test = await Deno.readTextFile("./test.txt");
return true
}
catch (err) {
return false;
}
}

Deno.test(async function t() {
const res = await test()
assertEquals(res, true)
})
import { assertEquals } from "https://deno.land/std@0.196.0/assert/assert_equals.ts"

export async function test() {
try {
const test = await Deno.readTextFile("./test.txt");
return true
}
catch (err) {
return false;
}
}

Deno.test(async function t() {
const res = await test()
assertEquals(res, true)
})
what version of deno are you using
L.literfieber7/27/2023
i found it it was a different function for sqlite where i forogt to close the db 😭 Thank you for your help anyways

Looking for more? Join the community!

Recommended Posts
Deno.Command arg with an asterisk?I am trying to execute a shell command from Deno, where one of the command args contains an asterisk`deno compile` in Nix results in `deno repl` starting instead of actual programI wrote following Nix impure derivation for my Deno app: ```nix packages.api = pkgs.stdenv.mkDerivat`@sentry/node` is throwing an export error on Deno DeployHello, this is my first time using Deno. I was trying to use the `@sentry/node` client on deploy, basync mapIs there anyway using the stdlib to map from one array to another array, with the work being done coHTTP 206 + HTML5 video streaming with Freshhow do I implement an endpoint to stream a video to a HTML video player using HTTP 206 in Fresh? Herrusty_v8 extracting stack trace when a promise rejectsHi, i am trying to get the stack trace and print it out when a promise rejects. ```rust if promise.sNode-API related segmentation faultAny idea what could be causing this crash? I'm using Node-API and the same module is working fine injwt generation and verificationjwt verification(using JOSE package) is working perfectly only when i have set b64 parameter insideHosting a node project on deploy?Can we host a NodeJS project using Deno Deploy or do we need some conversion first?anyone have a modern container workflow for the serverless framework?I was able to find code that executed at one point in time. It no longer does. I’d really like to iHow to deno up nuxt?**Setting up Nuxt3**: When learning more about V8 and the node.js architecture I became aware of dengoogle cloud SDKsHi all, I am building an application that interacts with google cloud apis, specifically google plaPrisma and denogetting this ```error: could not find package '.prisma' from referrer 'file:///Users/nikos/WebstormPDates don't increment correctlywhen I run the below function with the specific date 2023-09-30, I get the result of n-1 (for any nu