Skip to content

Commit

Permalink
doc: strengthen wording about fs.access() misuse
Browse files Browse the repository at this point in the history
PR-URL: #34352
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and addaleax committed Sep 22, 2020
1 parent 1d64c2c commit 7c7d3e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1124,8 +1124,8 @@ fs.access(file, fs.constants.F_OK | fs.constants.W_OK, (err) => {
});
```

Using `fs.access()` to check for the accessibility of a file before calling
`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Doing
Do not use `fs.access()` to check for the accessibility of a file before calling
`fs.open()`, `fs.readFile()` or `fs.writeFile()`. Doing
so introduces a race condition, since other processes may change the file's
state between the two calls. Instead, user code should open/read/write the
file directly and handle the error raised if the file is not accessible.
Expand Down

0 comments on commit 7c7d3e3

Please sign in to comment.