Skip to content
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

Racing issue on concurrent read #186

Open
davidliudev opened this issue Aug 27, 2022 · 3 comments
Open

Racing issue on concurrent read #186

davidliudev opened this issue Aug 27, 2022 · 3 comments

Comments

@davidliudev
Copy link

davidliudev commented Aug 27, 2022

During concurrent read it crashes on lockfile library.
It seems that the lockfile lib that this lib reference has a bug

https://github.com/npm/lockfile/blob/6590779867ee9bdc5dbebddc962640759892bb91/lockfile.js#L286

Notice that this line
var st = fs.statSync(path)
When it tries to read the path, the lock file is already being deleted by another concurrent read. Thus this line will throw and there is no catch. As a result this line crash with the following exception:

There is error loading the config  somefilename , err= Error: ENOENT: no such file or directory, stat 'somefilename.json.lock'
    at statSync (VM40 node:fs:1538:3)
    at e.statSync (VM116 asar_bundle:5:4539)
    at exports.lockSync (lockfile.js:286:1)
    at exports.lockSync (lock.js:84:1)
    at exports.getSync (storage.js:240:1)
    at exports.getSync (storage.js:243:1)
@davidliudev
Copy link
Author

Need either to patch the original lockfile lib (which the owner already archived it), or probably should fork that lib and fix this issue.

@jviotti
Copy link
Member

jviotti commented Sep 12, 2022

Hm, it might make sense to vendor lockfile through https://github.com/jviotti/vendorpull. I'll send a PR to do this, and then we can try to land a lockfile patch

jviotti added a commit that referenced this issue Sep 12, 2022
Given that we need to patch lockfile and such project is currently
archived.

See: #186
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti
Copy link
Member

jviotti commented Sep 12, 2022

OK, I vendored the module here: #187.

What is the patch you need on lockfile? Are you trying to retry fs.statSync? Given that you can reproduce the problem, if you have a patch you can confirm works for you, I'll happily apply it and release a new version :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants