Description
After opening a file with Deno.open
one receives a Deno.FsFile
type that has both .readable
and .writable
properties. The ambiguity is that these properties don't mention if one is still required to call .close()
when using these properties.
For example:
async function getX(): Promise<Response> {
const file = await Deno.open('path');
return new Response(file.readable)
}
With this code, it is ambiguous on if I need to add a way to know when .readable
is exhausted to call the .close()
or if it will cause a memory leak with the file hanging around until the program dies.
Some people on the Deno team has said that it does close itself once the .readable
is exhausted, but others have also not been so sure.
I am sure it is actually closing itself once exhausted but the ambiguity exists as the doc examples are also making use of the using
keyword which promises to clean itself up at the end of the scope, but using the using
keyword in the above example would cause an error to throw.