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

doc: warn about relying on fs gc close behavior #27972

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3733,9 +3733,14 @@ added: v10.0.0

A `FileHandle` object is a wrapper for a numeric file descriptor.
Instances of `FileHandle` are distinct from numeric file descriptors
in that, if the `FileHandle` is not explicitly closed using the
`filehandle.close()` method, they will automatically close the file descriptor
in that they provide an object oriented API for working with files.

If a `FileHandle` is not explicitly closed using the
benjamingr marked this conversation as resolved.
Show resolved Hide resolved
`filehandle.close()` method, they might automatically close the file descriptor
benjamingr marked this conversation as resolved.
Show resolved Hide resolved
and will emit a process warning, thereby helping to prevent memory leaks.
Please do not rely on this behavior in your code because it is unreliable and
your file may not be closed. Instead, always explicitly close `FileHandle`s.
Node.js may change this behavior in the future.

Instances of the `FileHandle` object are created internally by the
`fsPromises.open()` method.
Expand Down