Recently, I have been working on an open-source Deno project centered around automatically generating documentation for your code based on your tests.
During the testing process, particularly, when Deno interacts with external resources, I was getting a strange error that looked like this :
AssertionError: Test case is leaking resources.
Before {
…
}
After {
…
}
This is caused by Deno’s internal architecture which holds a record of open files, sockets and other concepts.
**You can close a single resource by its RID **:
function Deno.close(rid: number): void;
Some functions provide easy access to this RID id. For example:
const file: File = await Deno.open("/foo/bar.txt", { read: true});
Deno.close(file.rid);
#javascript #deno #testing #memory-leak #typescript