Skip to content

fs: add Blob support to writeFile and appendFile - #64611

Open
aelhor wants to merge 1 commit into
nodejs:mainfrom
aelhor:fs-writefile-blob
Open

aelhor wants to merge 1 commit into
nodejs:mainfrom
aelhor:fs-writefile-blob

Conversation

@aelhor

@aelhor aelhor commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

This PR addresses part of #61684 by adding Blob support to the writeFile / appendFile family:

  • fsPromises.writeFile(data)
  • fsPromises.appendFile(data) (also broadens the documented data union from {string|Buffer} to the full set)
  • filehandle.writeFile(data)
  • filehandle.appendFile(data)

Implementation

A Blob is converted to a web ReadableStream via blob.stream() and consumed through the existing async-iterable path in writeFile. This is a small, ~6-line change that reuses existing infrastructure. Native zero-copy via a C++ blob handle is explicitly deferred as future work.

Tests

New test/parallel/test-fs-writefile-blob.js covers all 4 entry points, plus empty blob, binary blob, large blob (multi-chunk), explicit encoding option, and AbortSignal cancellation.

Scope: this covers the writeFile/appendFile portion of the issue's first ask. Remaining items from #61684 (the positional filehandle.write(blob), and the web fs.createWritableStream counterpart) will be tracked as separate follow-up PRs to keep this focused.

Refs: #61684

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Jul 19, 2026
Allow writeFile() and appendFile() (and their FileHandle
variants) to accept a Blob, converting it to a web
ReadableStream via blob.stream().

Signed-off-by: Ahmed Elhor <aelhor90@gmail.com>
@aelhor
aelhor force-pushed the fs-writefile-blob branch from d6945db to e8258fd Compare July 20, 2026 22:48
@codecov

codecov Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.13%. Comparing base (00917ba) to head (e8258fd).
⚠️ Report is 1347 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64611      +/-   ##
==========================================
- Coverage   90.14%   90.13%   -0.02%     
==========================================
  Files         741      741              
  Lines      242076   242081       +5     
  Branches    45558    45553       -5     
==========================================
- Hits       218216   218190      -26     
- Misses      15385    15401      +16     
- Partials     8475     8490      +15     
Files with missing lines Coverage Δ
lib/internal/fs/promises.js 93.01% <100.00%> (+0.01%) ⬆️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aelhor

aelhor commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Could someone from the fs team take another look at this? The previous approval became stale after the latest changes, and the PR now just needs one reapproval to unblock the merge. Thanks!

@aelhor
aelhor requested a review from jasnell August 26, 2026 08:58
@aelhor

aelhor commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

@jasnell Friendly ping when you have a moment. I corrected only the commit message; the code itself is unchanged, but this made the previous approval stale. Could you please review and re-approve the latest commit? Thank you!

@MikeMcC399 MikeMcC399 added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 30, 2026
@MikeMcC399

This comment was marked as resolved.

@aelhor

aelhor commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

the issue actually asks. Use this corrected body instead:

Does this text belong in the PR text? It looks like it was an agent-generated instructions.

You are right, I updated the pr body

@MikeMcC399 MikeMcC399 removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 30, 2026
@MikeMcC399

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@MikeMcC399

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@MikeMcC399 MikeMcC399 added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 30, 2026
@MikeMcC399

Copy link
Copy Markdown
Contributor

Jenkins CI is showing successful, so I've marked the PR as author ready PRs with CI started, the required approvals, and no outstanding review comments.

@aelhor

aelhor commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

Jenkins CI is showing successful, so I've marked the PR as author ready PRs with CI started, the required approvals, and no outstanding review comments.

Thanks @MikeMcC399 for running the CI and updating the status!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants