question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cant receive ipc msg after webpack hot reload

See original GitHub issue

main.js ipcMain.answerRenderer(IPCMsg.GetConfig, () => { return config.data })

renderer.js async load () { let data = await ipcRenderer.callMain(IPCMsg.GetConfig) console.log(data) }

Everything is normal at startup, but after modifying some code to trigger a hot update, ipcRenderer can only send messages, can’t receive messages.

In electron-better-ipc/source/renderer.js:6 const ipc = Object.create(ipcRenderer); Modify to const ipc = ipcRenderer; Fixed this bug

I don’t know why

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Jun 1, 2020

You chose to provide a “better” IPC (hence the name of the package!), so you wanted all standard APIs to also exist in your exported object. Am I correct?

Correct

0reactions
papbcommented, Jun 1, 2020

@sindresorhus Thanks for the response. Makes sense. Although when I asked, I was thinking of the following alternative:

- const ipc = Object.create(ipcMain || {});
+ const ipc = {};

And then in the places where you use standard electron IPC APIs:

- ipc.off(dataChannel, onData);
+ ipcMain.off(dataChannel, onData);

But I think I know the answer. You chose to provide a “better” IPC (hence the name of the package!), so you wanted all standard APIs to also exist in your exported object. Am I correct?

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack-dev-server hot reload not working - Stack Overflow
After reload the "Webpack Dev Server", the "Hot Reload" works, at least, after saving any change in CSS or JS files.
Read more >
DevServer - webpack
If you want to manually recompile the bundle, navigating to the /webpack-dev-server/invalidate route will invalidate the current compilation of the bundle and ...
Read more >
fork-ts-checker-webpack-plugin - npm
Runs typescript type checker and linter on separate process.. Latest version: 7.2.14, last published: 14 days ago.
Read more >
Interop's Labyrinth: Sharing Code Between Web & Electron ...
Things aren't always what they seem in this place, so you can't take anything ... but since these remote method calls boil down...
Read more >
webContents | Electron
Emitted when the renderer process sends an asynchronous message via ipcRenderer.send() . See also webContents.ipc , which provides an IpcMain -like interface ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found