Skip to content

JSON corruption due concurrent file write #258

Description

@vird

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions