SUMMARY OF THE PROBLEM

Recently, I have been working on an open-source Deno project centered around automatically generating documentation for your code based on your tests.

animyrch/doc

testing-based documentation module for Deno. Contribute to animyrch/doc development by creating an account on GitHub.

github.com

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 {
…
}

SOLUTION

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

Deno: Test Case Is Leaking Resources.
1.70 GEEK