We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b7f36e1 commit d97ea06Copy full SHA for d97ea06
doc/api/fs.markdown
@@ -595,6 +595,13 @@ Then call the `callback` argument with either true or false. Example:
595
util.debug(exists ? "it's there" : "no passwd!");
596
});
597
598
+`fs.exists()` is an anachronism and exists only for historical reasons.
599
+There should almost never be a reason to use it in your own code.
600
+
601
+In particular, checking if a file exists before opening it is an anti-pattern
602
+that leaves you vulnerable to race conditions: another process may remove the
603
+file between the calls to `fs.exists()` and `fs.open()`. Just open the file
604
+and handle the error when it's not there.
605
606
## fs.existsSync(path)
607
0 commit comments