electron-userland / electron-json-storage

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

Uncaught Exception: Error: EPERM: operation not permitted, rename #204

Open Niokx opened 1 year ago

Niokx commented 1 year ago

I am getting this error, when changing a slider value "too" fast inside the GUI, the slider value gets written to a "config.json". I am using the latest version for the json read/write, any idea how I can fix this issue or avoid it or just suppress the error message and try again?

With Electron I am getting the error "A JavaScript error occurred in the main process"

Uncaught Exception: Error: EPERM: operation not permitted, rename 'C:\Users\user\AppData\Roaming\Electron\storage\config.json.1464805734' -> 'C:\Users\user\AppData\Roaming\Electron\storage\config.json'

Screenshot 2023-03-25 151244

jviotti commented 1 year ago

Hi @Niokx,

These renames happen internally as a way to make atomic writes. On Windows, I have seen this happening often due to anti-virus software, etc (including Defender) locking files for analysis and preventing certain I/O operations altogether while they run.

Can you try to catch this error, check if it is EPERM and if so try the operation you were initially trying to do again? My understanding is that if AV software is getting in between, retrying enough will make it work.

Let me know how it goes. If it does fix the problem, I could try doing the try internally.