Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pd4d10 opened this issue May 9, 2021 · 4 comments
Closed

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

pd4d10 opened this issue May 9, 2021 · 4 comments
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. fs Issues and PRs related to the fs subsystem / file system.

Comments

@pd4d10
Copy link
Contributor

pd4d10 commented May 9, 2021

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'
  // }
})
@aduh95 aduh95 added errors Issues and PRs related to JavaScript errors originated in Node.js core. fs Issues and PRs related to the fs subsystem / file system. labels May 9, 2021
@RaisinTen
Copy link
Contributor

Are you expecting Windows to return an EBADF instead of an EPERM just like Linux does?

@RaisinTen
Copy link
Contributor

RaisinTen commented May 19, 2021

PR to do that: libuv/libuv#3303

@RaisinTen
Copy link
Contributor

The fix landed in #41398, closing! :)

@vtjnash
Copy link
Contributor

vtjnash commented Mar 7, 2022

Duplicate of #16596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests

4 participants