Skip to content

fs: fix writeFile[Sync] for non-seekable files

Currently writeFile and writeFileSync perform a positioned write at the beginning of the file, which prevents them from working with non-seekable files (#31926 (closed)).

Positioned writes were first removed for createWriteStream (#19329) and for custom FDs (#23433 (closed), #23709) as well as for files opened in append mode... but they're still used for filenames in normal mode. This PR removes positioned writes completely, as they're not needed for this case either.

This also makes it consistent with readFile (which does work with non-seekable files).

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included ← I'd like to test for this, but I can't find an OS-independent way of doing it...
  • documentation is changed or added ← should we mention this change?
  • commit message follows commit guidelines

Merge request reports

Loading