question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parallel processes can collide during fs calls, resulting in malformed data and/or thrown errors

See original GitHub issue

The 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. Every set or delete issues 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. Seems to make no difference && race conditions with FSWatchers
  • 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
screen shot 2017-04-04 at 8 05 01 pm

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Apr 24, 2017

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-mocha with the --debug switch and put a debugger statement in tests/settings.js inside 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.js

Maybe 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?

0reactions
nathanbucharcommented, Jun 7, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found