-
Notifications
You must be signed in to change notification settings - Fork 633
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
ensureDir
and ensureDirSync
are racy
#3233
Comments
We switched the order of Now a PR was created to mitigate that situation, but the solution looks very complex. #4008 Should we follow the direction of #4008 or should we revert back to pre-#3242 state, accepting some racy nature of it? (In my view, |
Accepting the racy nature of the function seems more reasonable and better than a complex solution as long as there's clear notice within the documentation, like |
These functions should not be racy. If that means you sometimes need write permissions instead of read permissions, that seems like a reasonable trade-off to me. |
@kt3k i opened this bug because I was using it in high concurrency and my code would randomly crash. I think this function being racy is not acceptable. |
They do
lstat
thenmkdir
rather than doing onlymkdir
and throwing an error.If you call
ensureDir
quickly enough in parallel, one of the twoensureDir
's will throw "AlreadyExists"."exists" checks using something like
lstat
are wrong 99% of times, and this is no exception :)The text was updated successfully, but these errors were encountered: