electron-userland / electron-json-storage

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

EPERM: operation not permitted, rename #125

Open paulius005 opened 5 years ago

paulius005 commented 5 years ago

We have recently released an update of our app to production with a switch to electron-json-storage over https://www.npmjs.com/package/electron-store because I saw #122 and #124 implemented.

We have started to get a lot of EPERM: operation not permitted, rename 'HOME\AppData\Roaming\Loom\storage\preferences.json.3783979581' -> 'C:\Users\[USER_NAME]\AppData\Roaming\Loom\storage\preferences.json'

and

Error: EBUSY: resource busy or locked, rename 'C:\Users\[USER_NAME]\AppData\Roaming\Loom\storage\selected_audio_device.json.747280505' -> 'C:\Users\[USER_NAME]\AppData\Roaming\Loom\storage\selected_audio_device.json'

What could be the cause here? We also to make sure to always await every set and get that we do

Happy to contribute if you could point me in the right direction as well :)

paulius005 commented 5 years ago

We are on 4.1.6

vhmth commented 5 years ago

We are also getting EBUSY. Presumably same issue bubbled up as a different FS error.

NickPepper commented 4 years ago

The same issue with "EPERM ... rename..." using version 4.1.8 - on Windows and on release build of my Electron app only (on 'development' environment all is OK as well as on all *nixes). Any hints or news?

jviotti commented 4 years ago

I believe the rename operations are due the atomic write features, but there must be an underlying issue with Windows that prevents them from happening.

How reliably can you reproduce this errors? Does it happen every time or rarely?

Do you have any anti-virus software installed on those machines?

on Windows and on release build of my Electron app only (on 'development' environment all is OK as well as on all *nixes). Any hints or news?

I heard about some anti-virus softwares that attempt to automatically quarantine files in certain locations by moving them away, scanning them in a safe place, and putting them back in (which could be causing EBUSY and EPERM as electron-json-storage is kept waiting on the file, or loses permissions to it).

These programs usually don't scan the whole hard drive, but certain system locations. It could be that the path you use for local development is not included in these quarantine paths, but it is once you globally install it in the system?

Can you confirm you are using one of these programs (I guess Windows Defender counts) and that it works if you try to whitelist the paths where the Electron app is installed?

mifi commented 4 years ago

All Node.js database modules using write-file-atomic are suffering from this. See https://github.com/sindresorhus/electron-store/issues/103 Windows rename function tends to fail a lot, especially due to antivirus. workaround is to retry.