Minor coding issue: fs.exists[Sync]() fs.stat() fs.access() immediately BEFORE fs.openFile() or fs.read/writeFile() #1763
danielweck
started this conversation in
Developer corner
Replies: 1 comment
-
An issue worth keeping alive, but as a developer discussion until it is actionable more broadly in the codebase. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://nodejs.org/api/fs.html
=>
Now, in practice in both Thorium and the
r2-xxx-js
components, there is no possible scenario where separate processes can potentially access the same resource "at the same time", in such a way that this would cause the aforementioned race condition. In other words, there is no possibility of a microtask tick betweenfs.exists()
andfs.readwrite()
in the I/O event queue resulting infs.exists()
being invalidated.That being said, good coding practice should be followed and I think we should review the code that deals with file access in our codebase(s). https://github.com/edrlab/thorium-reader/search?q=fs.existsSync
Beta Was this translation helpful? Give feedback.
All reactions