sindresorhus / electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
MIT License
4.6k stars 150 forks source link

WebContents #1 called ipcRenderer.sendSync() with 'electron-store-get-data' channel without listeners. #212

Closed medi11 closed 2 years ago

medi11 commented 2 years ago

I keep getting this warning whenever I add electron-store. Which leads to a frozen window. on frontend

const Store = window.require("electron-store");
const store = new Store();

on backend

    const mainWindow = new electron.BrowserWindow({
    title: "DOCTOR",
    show: false,
    webPreferences: {
        devTools: !app.isPackaged,
        nodeIntegration: true,
        contextIsolation: false,
        webSecurity: app.isPackaged,
    },
   });

electron: ^16.0.4 electron-store: ^7.0.3

sindresorhus commented 2 years ago

Try upgrading to the latest version.

medi11 commented 2 years ago

It is still the same, nothing changed.

SStoliarchuk commented 2 years ago

Can confirm this issue is present on latest version:

"dependencies": {
    "electron-is-dev": "1.2.0",
    "electron-store": "8.0.1",
    "express": "4.17.1",
    "get-port": "5.1.1",
    "react": "17.0.2",
    "electron": "16.0.5",
    "react-dom": "17.0.2"
}
const mw = new BrowserWindow({
    webPreferences: { 
        nodeIntegration: true,
        contextIsolation: false,
    },
});
SStoliarchuk commented 2 years ago

@medi11

In the main process, add these lines and it fixes the issue

const ElectronStore = require('electron-store');
ElectronStore.initRenderer();
medi11 commented 2 years ago

@medi11

In the main process, add these lines and it fixes the issue

const ElectronStore = require('electron-store');
ElectronStore.initRenderer();

Thank you @SStoliarchuk, that fixed the issue.