Skip to content

fix(ext/node): fs.writeFile and FileHandle.writeFile compatibility#32077

Merged
Tango992 merged 20 commits intodenoland:mainfrom
Tango992:fix-node-fs-write-file
Feb 9, 2026
Merged

fix(ext/node): fs.writeFile and FileHandle.writeFile compatibility#32077
Tango992 merged 20 commits intodenoland:mainfrom
Tango992:fix-node-fs-write-file

Conversation

@Tango992 Tango992 marked this pull request as draft February 6, 2026 09:31
@Tango992 Tango992 marked this pull request as ready for review February 6, 2026 13:09
@Tango992 Tango992 marked this pull request as draft February 6, 2026 14:45
@Tango992 Tango992 added the ci-draft Run the CI on draft PRs. label Feb 6, 2026
@Tango992 Tango992 marked this pull request as ready for review February 8, 2026 02:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves Deno’s node:fs polyfill compatibility for fs.writeFile, fs.writeFileSync, and related FileHandle.writeFile behaviors (towards #29972), aligning accepted input types, encoding handling, and some error mapping with Node’s expectations to unblock additional Node compat tests.

Changes:

  • Expand writeFile/writeFileSync data handling (TypedArrays, DataView, and (Async)Iterable chunks) and switch encoding validation to Buffer.isEncoding-based validation.
  • Add specialized denoWriteFileErrorToNodeError mapping (notably Windows errno behavior) and update validator typings.
  • Update unit tests + Node compat config to reflect the new compatibility surface; adjust core import map stream module specifiers from .mjs to .js.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/core_import_map.json Updates internal streams module mappings from .mjs to .js.
tests/unit_node/fs_test.ts Removes a test that assumed certain encodings were unimplemented.
tests/unit_node/_fs/_fs_writeFile_test.ts Updates assertions for Node-like error messages and expands encoding test cases.
tests/node_compat/config.jsonc Enables additional Node fs tests and marks test-fs-write-file.js as flaky.
ext/node/polyfills/internal/validators.mjs Tightens typing annotation for validateFunction.
ext/node/polyfills/internal/errors.ts Adds denoWriteFileErrorToNodeError for write-file specific error mapping.
ext/node/polyfills/_fs/_fs_writeFile.ts Core implementation changes for writeFile/writeFileSync: iterable support, chunking, abort checks, updated encoding validation, and updated error mapping.
ext/node/polyfills/_fs/_fs_common.ts Replaces legacy encoding checks with getValidatedEncoding() backed by assertEncoding().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bartlomieju
Copy link
Copy Markdown
Member

@Tango992 please take a look at the Copilot review.

@Tango992
Copy link
Copy Markdown
Contributor Author

Tango992 commented Feb 9, 2026

Addressed @bartlomieju

Copy link
Copy Markdown
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

Nice work, LGTM

@Tango992 Tango992 merged commit 0a6b424 into denoland:main Feb 9, 2026
21 checks passed
@Tango992 Tango992 deleted the fix-node-fs-write-file branch February 9, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run the CI on draft PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants