From 346c201c4ec6295900107022738edc31bd5635fe 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 a9abaf2695169e..b6e0004abff744 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1195,8 +1195,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.