From 7c7d3e3697191d040410c8291c9b890db2e09a61 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 13 Jul 2020 21:40:29 -0700 Subject: [PATCH] doc: strengthen wording about fs.access() misuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/34352 Reviewed-By: Ben Noordhuis Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- doc/api/fs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 822ba3be8780fb..55dd5f533fceb7 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -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.