node/lib/internal/fs
James M Snell 3f81645f8c fs: add autoClose option to FileHandle readableWebStream
By default, the `readableWebStream` method of `FileHandle` returns
a ReadableStream that, when finished, does not close the underlying
FileHandle. This can lead to issues if the stream is consumed
without having a reference to the FileHandle to close after use.
This commit adds an `autoClose` option to the `readableWebStream`
method, which, when set to `true`, will automatically close the
FileHandle when the stream is finished or canceled.

The test modified in this commit demonstrates one of the cases where
this is necessary in that the stream is consumed by separate code than
the FileHandle which was being left to close the underlying fd when
it is garbage collected, which is a deprecated behavior.

PR-URL: https://github.com/nodejs/node/pull/58548
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2025-06-04 18:26:54 -07:00
..
cp fs: improve cpSync dest overriding performance 2025-05-23 12:26:04 +00:00
read lib: remove unnecessary optional chaining 2024-11-07 15:59:12 +00:00
dir.js lib: make ERM functions into wrappers returning undefined 2025-05-25 13:44:43 +00:00
glob.js fs: add support for URL for fs.glob's cwd option 2025-05-11 17:29:45 +00:00
promises.js fs: add autoClose option to FileHandle readableWebStream 2025-06-04 18:26:54 -07:00
recursive_watch.js lib: fixup more incorrect ERR_INVALID_ARG_VALUE uses 2025-02-24 23:23:32 +00:00
rimraf.js fs: refactor rimraf to avoid using primordials 2024-09-10 02:32:57 +00:00
streams.js fs: move fs stream open method to eol 2025-06-02 16:54:31 +00:00
sync_write_stream.js lib: prefer logical assignment 2024-10-09 06:42:16 +00:00
utils.js lib: fixup incorrect argument order in assertEncoding 2025-02-24 23:23:32 +00:00
watchers.js lib: fixup more incorrect ERR_INVALID_ARG_VALUE uses 2025-02-24 23:23:32 +00:00