Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1c7 opened this issue Nov 15, 2021 · 7 comments

Comments

@1c7
Copy link

1c7 commented Nov 15, 2021

package.json

"electron": "^15.3.1",
"electron-better-ipc": "^2.0.1",

command

npm run electron

package.json

"scripts": {
  "dev": "vue-cli-service serve --silent"
}

image

@1c7
Copy link
Author

1c7 commented Nov 15, 2021

Flie 1: index.js

(not the entire file, but the most important part)

const { app } = require('electron')
const { ipcMain: ipc } = require('electron-better-ipc');

ipc.answerRenderer('app.getAppPath', async () => {
  var result = app.getAppPath();
  return result;
});


function createWindow() {
 win = new BrowserWindow({
    width: 820,
    minWidth: 820,
    height: 840,
    minHeight: 420,
    frame: false,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: true,
      contextIsolation: false,
    }
}

app.whenReady().then(() => {
  createWindow();

  app.on('activate', function () {
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
});

preload.js

window.require = require;

File 2: src/binaries.js

const { ipcRenderer: ipc } = window.require('electron-better-ipc');

async function getAppPath() {
  let app_path = await ipc.callMain('app.getAppPath');
  return app_path
}

(and few other function that depend on getAppPath())

@1c7
Copy link
Author

1c7 commented Nov 15, 2021

Seem like it didn't work. my app is getting a blank screen

image

@1c7
Copy link
Author

1c7 commented Nov 15, 2021

to be fair I am upgrading my Electron.js v10 app to v15.3.1
so there are a lot of issue.(I am removing a ton of remote code)
blank screen likely come from other issue

@chuac
Copy link

chuac commented Feb 5, 2022

I ran into something similar trying to use electron-store with Electron v16.0.0. Try calling initialize() and enable() to your index.js like this:

import { initialize, enable } from "@electron/remote/main";

initialize();
// ...
const win = new BrowserWindow({ ... });
enable(win.webContents);

@Eve-Sama
Copy link

It happens to me.

"electron": "^20.1.3",

But require @electron/remote/main and call initialize(), enable() do not work for me.

@Eve-Sama
Copy link

Add below code in main.js

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

It works for me!

@magnumxpm
Copy link

Add below code in main.js

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

It works for me!

This resolves the issue it seems.
I Used it like this:

import Store from "electron-store"
Store.initRenderer()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants