Parallel processes can collide during fs calls, resulting in malformed data and/or thrown errors
See original GitHub issueThe main and renderer process run in different threads, so it’s possible for the main and renderer electron-settings instances to collide when accessing the file system if they attempt to read/write the file at the same time. It should be noted that this issue is not unique to any version of electron-settings, nor electron-settings itself—any framework that can run in both processes that interact with the same file on the filesystem can encounter this problem.
This results in JSON.parse errors or, if the user is lucky, electron-settings will spot malformed JSON and reset the settings to fail gracefully, resulting in loss of data.
Possible solutions
Save the settings to a cached object and manipulate that instead. EverySeems to make no difference && race conditions with FSWatcherssetordeleteissues a throttled request to save the file to disk, so as to make interaction with the file-system far less frequent and decrease likelihood of collisions.- Suggest using
require('electron').remote.require('electron-settings')in the render process to use the main processes’ electron-settings instance. - Suggest using electron-settings in only one process, or sparingly in the other.
- Instead of throwing, just try to read the settings file again.
- Find a way to ensure that the electron-settings instance is shared between both processes.
- Find a way to check if the file is in use before attempting to access it.
- Use IPC in the renderer to ask the main process’ instance to save the file
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
ORA-12801: error signaled in parallel query server
The ORA-12801 is an Oracle error that has some confusing origins, but is described as an error resulting in some form from a...
Read more >Untitled - Snap!
Recursively sort the rest of the list, then insert the one left-over item ... ,data,government,says,others,ever,yet,research,done,left,far,large,called ...
Read more >Exception handling (Task Parallel Library) - Microsoft Learn
Explore exception handling using the Task Parallel Library (TPL) in .NET. See nested aggregate exceptions, inner exceptions, unobserved task ...
Read more >www.nessus.org/u?4ab370c4
If poll is called while there is data waiting to be read in the TLS layer but not at the network layer, the...
Read more >heat conduction losses: Topics by Science.gov
This model results in the temperature time slope taking the mathematical form of exponential decay. When data is found to fit well to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That really does make no sense! You explicitly bind it to the Observer here. And you definitely call it with the right context.
@nathanbuchar run
electron-mochawith the--debugswitch and put adebuggerstatement intests/settings.jsinside the"watch()"tests - I think our issue might be somewhere in the message passing between the main and renderer process.Stepping through the breakpoints takes us to:
electron-settings/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.jsMaybe this is a Chromium / electron bug with keeping context over
ipc? Perhaps the context isn’t passed from the main process to the renderer process for some reason?Closing this as it pertains to an older version of Electron Settings. A new major release (v4) of Electron Settings was just released! This new version should be much more reliable