nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

LocalStorage reload failure

Open jssuttles opened this issue 1 year ago • 3 comments

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

jssuttles avatar Dec 23 '24 16:12 jssuttles

@rogerwang Is this a bug or intended behaviour?

ayushmanchhabra avatar Apr 26 '25 04:04 ayushmanchhabra

@jssuttles could you provide a sample to reproduce?

rogerwang avatar May 01 '25 03:05 rogerwang

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

jssuttles avatar May 13 '25 16:05 jssuttles

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

ssnangua avatar Jul 19 '25 01:07 ssnangua