Commit Graph
419 Commits
Author SHA1 Message Date
Kirill Saied d9d4446bec fs: add windowsHandle option to file streams
Fixes: https://github.com/nodejs/node/issues/57288
Signed-off-by: PickBas <sayed.kirill@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63851
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
2026-08-06 21:24:40 +00:00
Archkon 111a62d9b8 fs: key glob matcher cache by platform
Glob matchers capture the path platform when they are created. Include
the platform in the cache key so path.posix and path.win32 do not share
incompatible matchers for the same pattern.

Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/64571
Fixes: https://github.com/nodejs/node/issues/64570
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-07-30 16:14:23 +00:00
bq b8f81e9760 fs: add pattern cache for matchGlobPattern()
Signed-off-by: Adam Haglund <adam@haglund.dev>
PR-URL: https://github.com/nodejs/node/pull/63915
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-07-17 21:34:39 +00:00
Kirill Saied 665daeb54c fs: do not treat EPERM as ENOTEMPTY on Windows
Fixes: https://github.com/nodejs/node/issues/56433

Signed-off-by: PickBas <sayed.kirill@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63709
Fixes: https://github.com/nodejs/node/issues/56433
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
2026-06-21 01:31:38 +00:00
RafaelGSS a929332960 permission: disable FileHandle utimes with permission model
PR-URL: https://github.com/nodejs-private/node-private/pull/873
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-48935
Refs: https://hackerone.com/reports/3625987
2026-06-18 06:29:24 +02:00
Matteo Collina de67c5ca63 fs: support caller-supplied readFile() buffers
Signed-off-by: Matteo Collina <matteo.collina@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63634
Fixes: https://github.com/nodejs/node/issues/63600
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-06-13 10:08:05 +00:00
Antoine du Hamel 1778eeb6e4 lib: add lint rule to enforce use of kEmptyObject
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63790
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-06-10 10:56:56 +00:00
Marco 716a92effc fs: prevent spurious recursive watch events on prefix siblings
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63095
Fixes: https://github.com/nodejs/node/issues/58868
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-06-09 04:53:43 +00:00
Trivikram Kamat 4d7996fb56 fs: ignore deleted dirs in recursive watch scan
A recursively watched directory can be removed after a parent watcher
observes it but before the non-native recursive watcher scans it.

Ignore ENOENT from the directory scan so this deletion race does not
emit an unhandled watcher error.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63686
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-06-01.md#jstest-failure
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-06-03 05:34:23 +00:00
sangwook 75b16f1f4e test_runner: avoid recompiling coverage globs for every file
`shouldSkipFileCoverage()` called `matchGlobPattern()` for each covered
file, and `matchGlobPattern()` builds a fresh Minimatch (a full glob
parse and regexp compile) on every call. The coverage exclude/include
globs never change during a run, so the same patterns were recompiled
once per file, which dominated the coverage report time.

Compile `coverageExcludeGlobs`/`coverageIncludeGlobs` to matchers once
per `TestCoverage` instance and reuse them for every file. Expose
`createMatcher()` from `internal/fs/glob` for this.

On a synthetic 200-test-file project this drops shouldSkipFileCoverage
from ~117ms to ~11ms (cpu-prof, isolation=none); the saving scales with
files * globs.

Refs: https://github.com/nodejs/node/issues/55103
Signed-off-by: sangwook <rewq5991@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63675
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-06-02 14:44:23 +02:00
Filip Skokan 1ee129df8f fs: coerce -0 to +0 in mode flags and watch intervals
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63556
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-05-31 14:25:29 +00:00
Matteo Collina 569369f927 vfs: dispatch fs/promises to mounted VFS instances
Add mount/unmount lifecycle on `VirtualFileSystem`, a handler registry
that fs.js and fs/promises.js consult via `vfsState.handlers`, and a
router that maps absolute paths to the VFS that owns them. When a VFS
is mounted, the public `fs.*` and `fs/promises` APIs (including
streams, `fs.watch`, and `opendir`) dispatch to the provider for paths
under the mount point, and fall through to the real filesystem
otherwise. Includes per-method dispatch tests, error-path coverage,
multi-mount routing tests, and router unit tests.

Ref: https://github.com/nodejs/node/pull/63115

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/63537
Refs: https://github.com/nodejs/node/pull/63115
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-05-29 17:57:34 +00:00
Trivikram Kamat 92f48f43fe tools: enforce iterator result property order
Add a custom ESLint rule requiring iterator result objects to place
`done` before `value`, and update existing lib iterator result objects
to follow the rule.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63526
Reviewed-By: Mattias Buelens <mattias@buelens.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-05-26 17:19:42 +00:00
James M Snell fb49d36956 quic: improve the quic js structure
* Adds invalid this protections in the stats classes
* Collects internal private fields into a single private symbol
  to reduce the number of private field accesses
* Adds and corrects isQuic* class checks
* Preserve stream id and direction after destroy
* Improve stats close snapshotting
* Fixes a handful of other bugs and doc issues

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/63267
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-05-21 14:16:46 -07:00
Livia Medeiros 4ee756741b fs: add Temporal.Instant support to Stats and BigIntStats
Signed-off-by: LiviaMedeiros <livia@cirno.name>
PR-URL: https://github.com/nodejs/node/pull/60789
Refs: https://github.com/nodejs/node/issues/57891
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-05-18 22:18:00 +00:00
LiviaMedeiros a9b0a83e82 fs: make Date properties on Stats enumerable
Signed-off-by: LiviaMedeiros <livia@cirno.name>
PR-URL: https://github.com/nodejs/node/pull/63328
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-05-17 20:45:21 +08:00
James M Snell cf91d181fb quic: complete the internal implementation of QUIC
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode:Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/62876
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-05-05 19:16:19 -07:00
Matteo Collina 4744070f51 fs: add followSymlinks option to glob
PR-URL: https://github.com/nodejs/node/pull/62695
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-04-24 21:52:52 +00:00
Edy Silva ed05549e5b fs: validate position argument before length === 0 early return
PR-URL: https://github.com/nodejs/node/pull/62674
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-04-14 22:09:32 +00:00
Efe 726b22048a watch: fix --env-file-if-exists crashing on linux if the file is missing
PR-URL: https://github.com/nodejs/node/pull/61870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-04-10 22:06:36 +00:00
Jinho Jang f8ee196c15 fs: expose frsize field in statfs
Expose `f_frsize` from libuv's `uv_statfs_t` as `statfs.frsize`.

Per POSIX, `f_blocks`, `f_bfree`, and `f_bavail` are expressed in
units of `f_frsize`, not `f_bsize`. On most filesystems the two
values are typically equal, but some filesystem drivers report a
different `f_bsize`, making it impossible to compute accurate disk
usage without `frsize`.

Refs: https://github.com/libuv/libuv/issues/4983
PR-URL: https://github.com/nodejs/node/pull/62277
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-03-31 20:51:44 +00:00
James M Snell ae7c6a7767 stream: add stream/iter Implementation
Experimental implementation of https://stream-iter.jasnell.me/

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-By: Claude/Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/62066
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-03-27 19:55:08 -07:00
RafaelGSS 3a04e0ff25 permission: include permission check on lib/fs/promises
PR-URL: https://github.com/nodejs-private/node-private/pull/795
Refs: https://hackerone.com/reports/3449392
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
CVE-ID: CVE-2026-21716
2026-03-24 19:46:45 -03:00
Juan José 31bf4fb6e5 fs: add throwIfNoEntry option for fs.stat and fs.promises.stat
Fixes: https://github.com/nodejs/node/issues/61116
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/61178
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-02-11 15:02:02 +00:00
Matteo Collina f70020305c fs: add ignore option to fs.watch
Add an `ignore` option to `fs.watch()` to filter filesystem events.
Supports string globs, RegExp, functions, or arrays of these.

PR-URL: https://github.com/nodejs/node/pull/61433
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-01-22 22:34:41 +00:00
Nicholas Paun 24b16509d4 fs: fix errorOnExist behavior for directory copy in fs.cp
PR-URL: https://github.com/nodejs/node/pull/60946
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-01-17 17:52:38 +00:00
sangwook 13a662f559 fs: fix ENOTDIR in globSync when file is treated as dir
`fs.globSync` failed with `ENOTDIR` when a path component in a glob
pattern was a file but used as a directory (e.g., 'foo{,/bar}' when
'foo' is a file).

This change aligns `getDirentSync` with the asynchronous `getDirent`
by wrapping the `lstatSync` call in a `try-catch` block to safely
return `null` on such errors.

Fixes: https://github.com/nodejs/node/issues/61257
PR-URL: https://github.com/nodejs/node/pull/61259
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-01-17 13:33:55 +00:00
RafaelGSS 3296b2e734 lib,permission: require full read and write to symlink APIs
Refs: https://hackerone.com/reports/3417819
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/760
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
CVE-ID: CVE-2025-55130
2026-01-13 17:02:08 +01:00
Efe 95852d7156 fs: validate statfs path
PR-URL: https://github.com/nodejs/node/pull/61230
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-01-03 03:01:34 +00:00
Robin van Wijngaarden 4db307a4b0 fs: detect dot files when using globstar
Using globstar in glob pattern should not prevent dot (hidden) files
from being matched.

PR-URL: https://github.com/nodejs/node/pull/61012
Fixes: https://github.com/nodejs/node/issues/56321
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-12-11 21:12:03 +00:00
Livia Medeiros 46dc5d7c9f lib: prefer call() over apply() if argument list is not array
PR-URL: https://github.com/nodejs/node/pull/60796
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-11-23 08:45:46 +00:00
René 196f5466af lib: revert to using default derived class constructors
PR-URL: https://github.com/nodejs/node/pull/59650
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-08-30 14:28:10 +00:00
Sylphy-0xd3ac 5794e644b7 fs: fix glob TypeError on restricted dirs
When a directory cannot be read due to permission issues, the async
version of fs.glob() returns null from readdir(), while the sync
version returns an empty array. This causes a TypeError when trying
to access the 'length' property of null.

PR-URL: https://github.com/nodejs/node/pull/58674
Fixes: https://github.com/nodejs/node/issues/58670
Fixes: https://github.com/nodejs/node/issues/58276
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan-Arrowood <ethan@arrowood.dev>
Reviewed-By: Juan José <soyjuanarbol@gmail.com>
2025-08-01 07:25:18 -07:00
Alex Yang a93da0a329 fs: correct error message when FileHandle is transferred
PR-URL: https://github.com/nodejs/node/pull/59156
Fixes: https://github.com/nodejs/node/issues/59155
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2025-07-29 19:28:35 +00:00
Kevin Gibbons 9523c84c17 fs: add disposable mkdtempSync
PR-URL: https://github.com/nodejs/node/pull/58516
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2025-07-07 06:44:07 -07:00
Livia Medeiros 9ab976397d fs: close dir before throwing if options.bufferSize is invalid
PR-URL: https://github.com/nodejs/node/pull/58856
Fixes: https://github.com/nodejs/node/issues/58854
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-07-06 05:32:45 +00:00
Livia Medeiros d824914e61 fs: throw ERR_INVALID_THIS on illegal invocations
PR-URL: https://github.com/nodejs/node/pull/58848
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-06-28 16:58:54 +00:00
James M Snell eec0302088 fs: move rmdir recursive option to end-of-life
Has been runtime deprecated for ~ 5 years now. It's time.

PR-URL: https://github.com/nodejs/node/pull/58616
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2025-06-21 16:20:38 +00:00
René ce546e468a fs: make Dir disposers idempotent
PR-URL: https://github.com/nodejs/node/pull/58692
Refs: https://github.com/nodejs/node/pull/58206
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-06-20 19:03:34 +00:00
Livia Medeiros f2e99c5c16 fs: avoid computing time coefficient constants in runtime
PR-URL: https://github.com/nodejs/node/pull/58728
Fixes: https://github.com/nodejs/node/issues/58726
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2025-06-18 16:36:55 +00:00
Livia Medeiros 823ca6991f fs: make processReadResult() and readSyncRecursive() private
PR-URL: https://github.com/nodejs/node/pull/58672
Fixes: https://github.com/nodejs/node/issues/58671
Refs: https://github.com/nodejs/node/pull/41439
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
2025-06-14 17:23:47 +00:00
Philipp Dunkel 5f7dbf45a3 fs: allow correct handling of burst in fs-events with AsyncIterator
PR-URL: https://github.com/nodejs/node/pull/58490
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2025-06-10 16:27:17 +00:00
Dario Piotrowicz 3c351c272f fs: improve cpSync no-filter copyDir performance
move the logic in `cpSync` that copies a directory from
src to dest from JavaScript to C++ increasing its performance

Note: this improvement is not applied if the filter option is
      provided, such optimization will be looked into separately
PR-URL: https://github.com/nodejs/node/pull/58461
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2025-06-07 14:44:25 +00:00
Yuesong Jake Li 68bac3d798 fs: fix cp handle existing symlinks
PR-URL: https://github.com/nodejs/node/pull/58476
Fixes: https://github.com/nodejs/node/issues/58468
Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com>
2025-06-07 06:44:11 +00:00
Yuesong Jake Li 0e8ae91855 fs: fix cpSync handle existing symlinks
PR-URL: https://github.com/nodejs/node/pull/58476
Fixes: https://github.com/nodejs/node/issues/58468
Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com>
2025-06-07 06:44:10 +00:00
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
James M Snell a273674dee fs: move fs stream open method to eol
The `open()` method on fs read and write streams has been
deprecated for many years. It's time to remove it while
still allowing the open method to be monkeypatched since
that's still apparently a thing.

PR-URL: https://github.com/nodejs/node/pull/58529
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
2025-06-02 16:54:31 +00:00
Livia Medeiros 6c9a7cd61e lib: make ERM functions into wrappers returning undefined
PR-URL: https://github.com/nodejs/node/pull/58400
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2025-05-25 13:44:43 +00:00
Dario Piotrowicz 1a5ab963b8 fs: improve cpSync dest overriding performance
move the logic in `cpSync` that overrides existing
dest files from JavaScript to C++ increasing its performance

PR-URL: https://github.com/nodejs/node/pull/58160
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2025-05-23 12:26:04 +00:00
Antoine du Hamel 3ad7362012 fs: add support for URL for fs.glob's cwd option
PR-URL: https://github.com/nodejs/node/pull/58182
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
2025-05-11 17:29:45 +00:00