Skip to content

Correct the error type of fs.writeFile with read-only mode #38607

Description

@pd4d10

Refs: #38604 and #38604 (review)

const file = '/tmp/1.txt'
fs.writeFileSync(file, '') // Create first

fs.writeFile(file, 'hello', { flag: 'r' }, (err) => {
  console.log(err)
  // [Error: EBADF: bad file descriptor, write] {
  //   errno: -9,
  //   code: 'EBADF',
  //   syscall: 'write'
  // }
})

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

    errorsIssues and PRs related to JavaScript errors originating in Node.js core.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