-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More detailed fs
documentation
#4352
Comments
Your specific example about
In many cases they're light wrappers around their POSIX counterparts. This is hinted at if not outright mentioned in quite a few places in
There is no lock beyond the intrinsic synchronization that the operating system provides for concurrent requests, which isn't much. File locks are surprisingly broken. |
This is related to #4375 i.e. more detailed description of what |
What kind of synchronization is that? It's still unclear what will happen if two processes try to
Computers in general are. |
Yes, and I spent some time googling before posting ("posix", "posix file system api", etc.). That led me to unhelpful resources that explained little more than the acronym, or incredibly dense resources that were fairly overwhelming and I certainly could not find a "counterpart" for Honestly, the most helpful thing I have done so far is read the source, but that has hardly given me a definitive answer.
That would be a start, but I think it needs more. Obviously, it is a difficult to strike a balance between approachability and thoroughness on a topic like this, so maybe a link to an external resource is the best we can do. I would prefer it be one that was written for Node users, as much of the POSIX documentation I have found so far is pretty hard to grok. |
btw, this is something that I'm working on. expect a PR with significant modifications soon |
The documentation has seen (and continues to see) significant improvements since this issue was filed so I'll go ahead and close it out. Pull requests are of course still welcome. |
But the docs doesn't answer the questions that this issue is about:
I still have no idea what would happen. Running multiple Node.js processes is pretty common, so I'm very surprised no one else has asked this. // @jasnell |
Debatable whether that belongs in our documentation, besides maybe a note that it's unspecified behavior. The interaction of multiple processes writing to the same file is platform/file system-dependent and not specific to node. |
The
fs
docs provide a great overview of the API, but information on their low-level operations is pretty sparse.For example, I can't tell how two competing
fs.writeFileSync
calls from different processes will interact. Will an error be thrown by whichever process loses the race for the lock? Will the second process just wait for the lock and then overwrite the previous contents?For reference, here are two issues would have benefited from these sorts of details:
The text was updated successfully, but these errors were encountered: