LocalStorage reload failure
Issue Type
Before opening an issue, please search and see if it has already been raised.
-
[x] Bug Report
-
[ ] Feature Request
-
[x] Successfully reproduced against the latest version of NW.js?
Current/Missing Behavior
When restarting using window.chrome.runtime.reload(), for applications under load, global.localStorage and global.window.localStorage are undefined and cannot be set. If you do a full stop and start of the application, then it works again.
I use const store = require('store');
This behavior did not seem to happen in 0.91.0.
Expected/Proposed Behavior
When restarting the application using window.chrome.runtime.reload(), global.localStorage and global.window.localStorage should be defined.
Additional Info
- Operating System: Windows
- NW.js Version: 0.93.0
@rogerwang Is this a bug or intended behaviour?
@jssuttles could you provide a sample to reproduce?
https://github.com/jssuttles/nw-8243 Here's a repo. I tried it without the devtools, and it didn't happen, but after I turned on the devtools it seems to have broken.
Ran this on: Windows 11 Pro - Version 10.0.26100 Build 26100 NW.js Version: 0.99.1 - sdk
It seems that this issue also affects the loaded extensions:
// package.json
{
"name": "test",
"main": "index.html",
"chromium-args": "--load-extension='path/to/someExtension'"
}
// index.html
chrome.management.getAll((extensions) => {
const someExtension = extensions.find((extension) => extension.name === "someExtensionName");
if (someExtension) {
nw.Window.open(someExtension.optionsUrl, { new_instance: true });
}
});
In the extension's options window, the localStorage is null, this will affect some extensions.
Opening the options window through chrome://extensions/?id=someExtensionId will have the same result.
@rogerwang