Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with store creating multiple .temp files and having issues writing to it. #261

Closed
ratanservegar opened this issue Jul 19, 2023 · 5 comments

Comments

@ratanservegar
Copy link

Hi,

I have a stored named MasterStore and it creates a MasterStore.json files and everything works prefect. However, after sometime for some reason the .setCache function errors out because it is trying to access some MasterStore.json.temp file. below is the error log

Error: EPERM: operation not permitted, rename 'C:\Users\AppData\Roaming\neclient\MasterStore.json.tmp-900921090850e765' -> 'C:\Users\AppData\Roaming\neclient\MasterStore.json' at renameSync (node:fs:993:3) at attempt (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\utils\retryify.js:33:27) at attempt (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\utils\retryify.js:39:36) at attempt (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\utils\retryify.js:39:36) at Object.writeFileSync (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\atomically\dist\index.js:160:50) at ElectronStore._write (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\conf\dist\source\index.js:375:28) at set store [as store] (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\conf\dist\source\index.js:296:14) **at ElectronStore.set (C:\Users\AppData\Local\Programs\neclient\resources\app\node_modules\conf\dist\source\index.js:189:20) at Object.setCacheValue (C:\Users\AppData\Local\Programs\neclient\resources\app\system_services\cache-service.js:59:21)** at BeforeAppShutDown (C:\Users\AppData\Local\Programs\neclient\resources\app\main.js:352:23)

i crate the store using
const masterStore = new Store({ name: 'MasterStore' });
and set contents by masterStore.set(key, value);

can someone tell me whats the reason its doing this? and how i can fix it?

@sindresorhus
Copy link
Owner

The error is coming from https://github.com/fabiospampinato/atomically, so you should open an issue there instead.

@fabiospampinato
Copy link

fabiospampinato commented Jul 26, 2023

It's worth exploring switching to asynchronous writing rather than synchronous writing, as that gives atomically more time to retry operations, as in sync mode it will keep retrying operations for up to 1s, but in async mode it will try for up to 7.5s.

Other than that if Windows decides that a rename just is not allowed there's no way to perform an atomic write, so no way to fix this in atomically.

@ratanservegar
Copy link
Author

@fabiospampinato thanks for the reply, could you tell me how to change to async? is this something electron-store needs to implement or can i do it just for my app?

@ratanservegar
Copy link
Author

@sindresorhus seems like it something that needs to be done in electron-store, is this something you can accommodate? Thanks!

@mushan0x0
Copy link

Can you reopen it please? My project is also facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants