Skip to content

Commit 7c7d3e3

Browse files
Trottaddaleax
authored andcommitted
doc: strengthen wording about fs.access() misuse
PR-URL: #34352 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 1d64c2c commit 7c7d3e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/api/fs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,8 @@ fs.access(file, fs.constants.F_OK | fs.constants.W_OK, (err) => {
11241124
});
11251125
```
11261126

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

0 commit comments

Comments
 (0)