Skip to content

fs.writeFile doesn't work with non-seekable files #31926

Description

@mildsunrise
  • Version: 13.7.0
  • Platform: Linux
  • Subsystem: fs

I see that fs.writeFile* fails with non-seekable files, because it does a positioned write:

fs.writeFileSync('/sys/kernel/debug/tracing/trace_clock', 'mono')
openat(AT_FDCWD, "/sys/kernel/debug/tracing/trace_clock", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 19
pwrite64(19, "mono", 4, 0)              = -1 ESPIPE (Illegal seek)

fs.readFile works correctly since it does a regular read, and I also found that createWriteStream was fixed to work with non-seekable files (#19329).
Is this known/intentional? If not, would a fix be accepted? (I haven't investigated further yet)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions