Skip to content

Commit 346c201

Browse files
TrottMylesBorins
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 3d4f608 commit 346c201

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/api/fs.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,8 @@ fs.access(file, fs.constants.F_OK | fs.constants.W_OK, (err) => {
11951195
});
11961196
```
11971197

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

0 commit comments

Comments
 (0)