Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c566401

Browse filesBrowse files
benjamingrtargos
authored andcommitted
doc: warn about relying on fs gc close behavior
Warn about using the bahvior where file handles are closed automatically when the file is closed. PR-URL: #27972 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 6129376 commit c566401
Copy full SHA for c566401

File tree

Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+7-2Lines changed: 7 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3733,9 +3733,14 @@ added: v10.0.0
37333733

37343734
A `FileHandle` object is a wrapper for a numeric file descriptor.
37353735
Instances of `FileHandle` are distinct from numeric file descriptors
3736-
in that, if the `FileHandle` is not explicitly closed using the
3737-
`filehandle.close()` method, they will automatically close the file descriptor
3736+
in that they provide an object oriented API for working with files.
3737+
3738+
If a `FileHandle` is not closed using the
3739+
`filehandle.close()` method, it might automatically close the file descriptor
37383740
and will emit a process warning, thereby helping to prevent memory leaks.
3741+
Please do not rely on this behavior in your code because it is unreliable and
3742+
your file may not be closed. Instead, always explicitly close `FileHandle`s.
3743+
Node.js may change this behavior in the future.
37393744

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.