W-17915544 fix: don't lock directory #1169
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
whoever originally wrote this (jk, it's me!) locked the parent directory (ex: .sfdx) when creating files there (ex: auth files)
works fine on my machine, might delay things a tiny bit if I'm doing many parallelized things.
cliaas under load from thousands of sandboxes might wait a long time to get to create an auth file, and annoy users or timeout
proper-lockfile https://www.npmjs.com/package/proper-lockfile has the option to not try to resolve the file (by default it does, using realpath option default true)
This change means it puts a lock file in the target folder (ex: sfdx) and if someone else tries to create the same file (ex: auth file) they have to wait for my lock to expire, just like they would for a file that exists.
perf bonus: saves a bit of time for CLI doing fs.existsSync
[realpath option was there to resolve symlinks. None of our auth files are symlinks. If they're in a symlinked dir, it works as expected]
What issues does this PR fix or reference?
@W-17915544@