electron-userland / electron-json-storage

:package: Easily write and read user settings in Electron apps
1.43k stars 79 forks source link

Multi-instance read/write safety? #80

Closed randonia closed 7 years ago

randonia commented 7 years ago

I have occasionally run into an issue where my data will be corrupted in a way that appears to be due non-locked multi-process writes.

For example, the file will result like this:

{"foo": false,"bar": 42,"baz":12345}az":12345} This usually happens when it seems like two or more separate electron render processes are writing different values to the same location.

Is there an way to guarantee mutex locking or a different access/write pattern that I should follow? Right now almost all of my reads/writes are using Electron's remote object API, so theoretically they're using the same object instance to read/write.

Thanks!

[edit] I found a few places in our code where we weren't using the same instance object and therefore I'm assuming that was responsible for the existing lock protection not correctly working. I'll close the issue when I can verify resolution, but would like to leave this issue up in case anyone else stumbles upon this error googling problems.

randonia commented 7 years ago

Turns out this was fixed by #72 . We were using 3.0.5 :) Thanks for being a rubber :duck: