electron: localStorage doesn't persist on Linux + Windows
To repro:
- Open Electron on Ubuntu 14.04 32-bit (at least, prob. other places too)
localStorage.setItem('foo', 'bar')- Close the app
- Reopen the app
localStorage.getItem('foo')>> undefined
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 18 (10 by maintainers)
LocalStorage won’t persist if you kill the app via Ctrl-C or some other violent means, this is almost certainly the bug y’all are seeing
Are using localestorage from main process or renderer process ?
Even when using process.on(‘exit’, () => app.quit());
my renderer process seems to lose data in localstorage when closing the application with “X”
If you want to prevent this behavior, exit your application correctly and it won’t happen 💃
I have the same issue on win10 when I reinstall my electron app. I just remove C:\Users\Lt0\AppData\Roaming\my-app-name to make it work.
So, it turns out that we were calling out to
app.exitinstead ofapp.quit. I can’t find any documentation on this method, but modifying all of our calls to use quit makelocalStoragepersist as expected. I think we can close this one out. 😅