Skip to content

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

Closed
@pd4d10

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'
  // }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    errorsIssues and PRs related to JavaScript errors originated in Node.js core.fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions