electron-userland / electron-json-storage

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

file seems to be locked when setting the data after getting the data #89

Closed jgarza9788 closed 6 years ago

jgarza9788 commented 7 years ago

2017-10-08_12-59-30

jviotti commented 7 years ago

Is there any chance you can provide a stack trace? ie by printing the error object from the main process?

jgarza9788 commented 7 years ago

I was saving too often. A possible solution was to loop based on the error and re-save.

On Tue, Oct 10, 2017 at 2:55 AM Juan Cruz Viotti notifications@github.com wrote:

Is there any chance you can provide a stack trace? ie by printing the error object from the main process?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/electron-userland/electron-json-storage/issues/89#issuecomment-335422461, or mute the thread https://github.com/notifications/unsubscribe-auth/AHtIvlLh3SXFIWtZi3IccsYDdLCS-3kZks5sqz8SgaJpZM4Px1NE .

-- Justin Garza

(818) 251-0647 / jgarza9788@gmail.com

jviotti commented 7 years ago

@jgarza9788 Saving too often shouldn't be an issue. The test cases perform stress testing on the module, by very quickly writing a thousand entries, even in parallel (https://github.com/electron-userland/electron-json-storage/blob/master/tests/storage.spec.js#L51). Are you sure there is not something else going on with your app?

jviotti commented 6 years ago

Hi @jgarza9788. Good news! I believe I fixed this issue on this PR: https://github.com/electron-userland/electron-json-storage/pull/110. Would you mind giving a shot to confirm the issue is ruled out before merging and publishing?

Basically the problem was that the locking module I was using was not doing real locking, but just some checks in-memory within the same process, so writing the file from more than one process would trigger the issue.

Let me know!