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
@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.54%. Comparing base (3cac7b9) to head (70f0563).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64611      +/-   ##
==========================================
- Coverage   90.55%   90.54%   -0.01%     
==========================================
  Files         801      801              
  Lines      284215   284220       +5     
  Branches    54883    54895      +12     
==========================================
- Hits       257358   257347      -11     
- Misses      17014    17043      +29     
+ Partials     9843     9830      -13     
Files with missing lines Coverage Δ
lib/internal/fs/promises.js 91.87% <100.00%> (+0.01%) ⬆️

... and 34 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
Member

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!

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@aelhor

aelhor commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@gurgunday Thanks for the approval! All checks are passing, but GitHub still shows a required review and the needs-ci label remains. Is anything else needed from my side, or could a collaborator help land this when they have a moment? Thanks!

@MikeMcC399 MikeMcC399 removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Oct 25, 2026
@MikeMcC399

Copy link
Copy Markdown
Member

@aelhor

I'm not sure quite what has happened with this PR, but GitHub is saying it needs attention:

image

Because this PR branch is now more than 1758 commits behind main I would suggest that you rebase it according to the Pull requests documentation.

We can then ask the previous approvers to re-approve.


The needs-ci PRs that need a full CI run. label is a little confusing. It remains there whether or not a Jenkins CI run has been attempted or not.

See Testing and CI from the Collaborator Guide where it says:

The needs-ci label identifies pull requests that require a full Jenkins CI run. It is a classification, not an indication that CI is still pending. Leave it in place after CI completes.

@MikeMcC399

This comment was marked as resolved.

@aelhor

aelhor commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@aelhor

Are you intending to rebase this PR? It does need to go through a new review and Jenkins CI cycle, so it would make sense to have it updated beforehand.

@MikeMcC399 thanks for your comment, I will rebase it as soon as possible

@MikeMcC399

This comment was marked as resolved.

@aelhor

aelhor commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Hi @MikeMcC399 sorry for wait
i will do the rebase any time in the next 3 days.

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>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@MikeMcC399

Copy link
Copy Markdown
Member

Thanks for the rebase! I started a new Jenkins CI run. See https://ci.nodejs.org/job/node-test-pull-request/79457/

@aelhor

aelhor commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@MikeMcC399 Thanks for starting the new Jenkins CI run. It completed successfully, and all checks are green. The branch is now rebased onto the latest main. Is anything else needed from my side, or is this ready to be landed?

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

Copy link
Copy Markdown
Member

@aelhor
Congratulations on the Jenkins CI success!

The PR needs a new approval. Perhaps the original approvers:

@IlyasShabi and / or @gurgunday

could step in, approve and land the PR?

@gurgunday gurgunday added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 23, 2026
gurgunday
gurgunday previously approved these changes Nov 23, 2026

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@MikeMcC399
MikeMcC399 dismissed gurgunday’s stale review November 24, 2026 07:46

GitHub is still showing "Review required" even though there was an approval.

@MikeMcC399

Copy link
Copy Markdown
Member

@gurgunday

There is something strange with how GitHub is handling this PR. After your latest approval, the PR should show as approved, but it doesn't. I've dismissed your approval, and ask you to approve again. I hope that will work.

@MikeMcC399
MikeMcC399 requested a review from gurgunday November 24, 2026 07:49
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. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants