Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguity with Deno.FsFile docs #1111

Open
BlackAsLight opened this issue Nov 4, 2024 · 0 comments
Open

Ambiguity with Deno.FsFile docs #1111

BlackAsLight opened this issue Nov 4, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@BlackAsLight
Copy link

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.

@thisisjofrank thisisjofrank self-assigned this Nov 7, 2024
@thisisjofrank thisisjofrank added the documentation Improvements or additions to documentation label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants