From f1fffe5c7faf198504c1e7f6ea373421f0390bf1 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 da51978a886b10..6ecf2832cb8b18 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.