Repository navigation
Conversation
Collaborator
|
Review requested:
|
Contributor
|
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67937 +/- ##
==========================================
- Coverage 92.96% 90.60% -2.37%
==========================================
Files 432 803 +371
Lines 201044 287072 +86028
Branches 30705 55488 +24783
==========================================
+ Hits 186903 260093 +73190
- Misses 13814 17081 +3267
- Partials 327 9898 +9571
🚀 New features to boost your workflow:
|
Add first-class WHATWG Web Streams for reading and writing files, implemented in JS and faster than going through the createReadStream().toWeb() / createWriteStream() adapter path. The readable is a type:'bytes' ReadableStream that reads directly into BYOB / auto-allocated views (zero-copy); the writable is a WritableStream sink with partial-write handling. Both accept a path, FileHandle, or fd and the core options (flags, encoding, start/end, highWaterMark, autoClose). Includes tests (test/parallel/test-fs-create-web-readable.js and test-fs-create-web-writable.js), benchmarks comparing against the createReadStream/createWriteStream().toWeb() baseline, and docs. Signed-off-by: Matteo Collina <hello@matteocollina.com>
V8 CPU profiling (node --cpu-prof; @platformatic/flame could not attach to the v28-pre build because its @datadog/pprof native addon has no ABI 155 build) shows the file web streams are I/O-bound (majority idle waiting on thread-pool I/O); the non-idle CPU is dominated by the WHATWG stream machinery and native I/O bindings. In the write path, createWebWritable allocated a fresh Buffer view (FastBuffer) on every chunk. Reuse the chunk directly when it is already a Buffer, avoiding a per-chunk allocation. This removes the FastBuffer allocation and roughly halves GC time (7.9% -> 3.0%) in the write profile, with read/write benchmarks at or above the createReadStream/createWriteStream().toWeb() baseline. Signed-off-by: Matteo Collina <hello@matteocollina.com>
Add explicit coverage for the BYOB read path, which the existing read tests exercise only implicitly through the autoAllocateChunkSize default reader path: - reads via a BYOB reader into caller-provided buffers and verifies the concatenated bytes match the file; - verifies a BYOB read detaches (transfers) the caller-provided buffer (ArrayBuffer.byteLength becomes 0), the standard web-streams semantic; - verifies the stream does not reuse the same internal buffer across reads (mutating a returned chunk does not corrupt the next chunk). Signed-off-by: Matteo Collina <hello@matteocollina.com>
mcollina
force-pushed
the
feature/fs-webstreams
branch
from
December 1, 2026 17:05
c7c5799 to
68a6ddc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
fs.createWebReadable()andfs.createWebWritable(), which return first-class WHATWG Web Streams for reading and writing files. These are implemented in JS and skip the Node stream +stream.Readable.toWeb()/stream.Writable.toWeb()adapter hop.The readable is a
type: 'bytes'ReadableStreamthat reads directly into BYOB / auto-allocated views (zero-copy, supports BYOB readers); the writable is aWritableStreamsink with partial-write handling. Both accept a path, aFileHandle, or anfd, plus the core options (flags,encoding,start/end,highWaterMark,autoClose).Includes tests (test/parallel/test-fs-create-web-readable.js and test/parallel/test-fs-create-web-writable.js), read/write benchmarks comparing against the
createReadStream()/createWriteStream().toWeb()baseline, and documentation.