-
Notifications
You must be signed in to change notification settings - Fork 51
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
JSON corruption due concurrent file write #258
Comments
fix proposal vird@887b5bc |
Yikes! Good catch. If the Disklet node.js backend really has this problem, then it would affect other areas like login and blockchain syncing, as well. I think the proper fix needs to happen in Disklet itself, rather than the sync module, since that will fix everything at once. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Due internal actions of edge wallet it can corrupt WalletName.json
sample of corrupted file
{"encryptionType":0,"iv_hex":"KmI7"}nbccfS5KIQIGo9k2iPW3Zp8pxV2Zg4XGo5sG3qHCU="}
You can look at really similar problem here nodejs/node#7978
Problem is located here https://github.com/EdgeApp/edge-core-js/blob/master/src/core/storage/repo.js#L78
We can call saveChanges before other saveChanges is occurs and now disklet comes...
It has relatively slow file write https://github.com/EdgeApp/disklet/blob/master/src/backends/node.ts#L89
So it tries to write, can't, tries to make directory and write one more time.
That's enough for fast second saveChanges call.
So first deepWriteFile made directory and tries to write
second saveChanges call calls deepWriteFile and tries to write too.
The text was updated successfully, but these errors were encountered: