electron-react-boilerplate / electron-react-boilerplate/electron-react-boilerplate

localStorage is blank in packaged version only

Closed
#3,511 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
24.3k
Forks
4k
Avg merge
20m
Merged PRs (30d)
4

Description

## Prerequisites

- [x ] Using npm
- [x ] Using an up-to-date [`main` branch](https://github.com/electron-react-boilerplate/electron-react-boilerplate/tree/main)
- [x ] Using latest version of devtools. [Check the docs for how to update](https://electron-react-boilerplate.js.org/docs/dev-tools/)
- [x ] Tried solutions mentioned in [#400](https://github.com/electron-react-boilerplate/electron-react-boilerplate/issues/400)
- [x ] For issue in production release, add devtools output of `DEBUG_PROD=true npm run build && npm start`

## Expected Behavior

My application relies on window.localStorage.getItem() and window.localStorage.setItem(). These work between pages using react-router-dom MemoryRouter in development, but when I package, all localStorage is null.

## Current Behavior

The application displays blank fields from localStorage.

## Steps to Reproduce

1. Run npm run start

2. localStorage functionality works

3. Run npm run package

4. localStorage functionality doesn't work (blank)

## Possible Solution (Not obligatory)

## Context

I am trying to persist data between pages. For now I am using IPC calls to save state.

I do see these warnings running npm run start, I'm not sure if they're related:
```

(node:72382) ExtensionLoadWarning: Warnings loading extension at /Users/alana/Library/Application Support/[application]/extensions/fmkadmapgofadopljbjfkapdkoienihi:
Permission 'scripting' is unknown or URL pattern is malformed.

(Use `Electron --trace-warnings ...` to show where the warning was created)
[72382:0726/131900.358915:ERROR:render_process_host_impl.cc(3766)] Request for unknown Channel-associated interface: extensions.mojom.ServiceWorkerHost
[72382:0726/131900.363013:ERROR:extensions_browser_client.cc(67)] Extension Error:
OTR: false
Level: 2
Source: chrome-extension://padaoheoklmhfgbbfjaakkchnpkfoegd/build/background.js
Message: Uncaught TypeError: chrome.tabs.query is not a function
ID: padaoheoklmhfgbbfjaakkchnpkfoegd
Type: RuntimeError
Context: chrome-extension://padaoheoklmhfgbbfjaakkchnpkfoegd/build/background.js
Stack Trace:
{
Line: 208
Column: 1
URL: chrome-extension://padaoheoklmhfgbbfjaakkchnpkfoegd/build/background.js
Function: (anonymous function)
}
[72382:0726/131900.363636:ERROR:extensions_browser_client.cc(67)] Extension Error:
OTR: false
Level: 1
Source: manifest.json
Message: Service worker registration failed. Status code: 15
ID: padaoheoklmhfgbbfjaakkchnpkfoegd
Type: ManifestError
[72382:0726/131900.364104:ERROR:extensions_browser_client.cc(67)] Extension Error:
OTR: false
Level: 2
Source: chrome-extension://padaoheoklmhfgbbfjaakkchnpkfoegd/build/background.js
Message: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'ExecutionWorld')
ID: padaoheoklmhfgbbfjaakkchnpkfoegd
Type: RuntimeError
Context: chrome-extension://padaoheoklmhfgbbfjaakkchnpkfoegd/build/background.js
Stack Trace:
{
Line: 59
Column: 1
URL: chrome-extension://padaoheoklmhfgbbfjaakkchnpkfoegd/build/background.js
Function: (anonymous function)
}
```

## Your Environment

- Node version : 20.3.1
- electron-react-boilerplate version or branch : main
- Operating System and version : Mac OS Ventura 13.1
- Link to your project :

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.