fix(ext/node): fs.writeFile and FileHandle.writeFile compatibility#32077
Merged
Tango992 merged 20 commits intodenoland:mainfrom Feb 9, 2026
Merged
fix(ext/node): fs.writeFile and FileHandle.writeFile compatibility#32077Tango992 merged 20 commits intodenoland:mainfrom
fs.writeFile and FileHandle.writeFile compatibility#32077Tango992 merged 20 commits intodenoland:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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/writeFileSyncdata handling (TypedArrays, DataView, and (Async)Iterable chunks) and switch encoding validation toBuffer.isEncoding-based validation. - Add specialized
denoWriteFileErrorToNodeErrormapping (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
.mjsto.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.
Member
|
@Tango992 please take a look at the Copilot review. |
Contributor
Author
|
Addressed @bartlomieju |
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.
Towards #29972
Allows the following node compat tests to pass: