Arc
Arc

Reputation: 349

I don't seem to be able to use ipcRenderer in electron

Using electron 8.0.3 (but the issue is also apparent with 8.1.0). The HTML page loads fine until I use ipcRenderer. Here is the Javascript code which I am including in the page:

const {ipcRenderer} = require('electron');

ipcRenderer.sendSync('testSync', 'sync ping');

When this is included I get the following error in the developer console in electron:

electron/js2c/renderer_init.js:1095 Uncaught Error: Unable to deserialize cloned data due to invalid or unsupported version.
    at EventEmitter../lib/renderer/api/ipc-renderer.ts.ipcRenderer.sendSync (electron/js2c/renderer_init.js:1095)
    at login.js:4

Any ideas? This is a freshly created project. I'm not even sure what the error is referring to with "invalid or unsupported version". I also get just a white screen in the electron window because the error is not caught, but even if I try to catch it, the process still dies.

Upvotes: 0

Views: 1096

Answers (1)

Arc
Arc

Reputation: 349

The issue was JQuery. By adding the following code block from the electron docs, before JQuery was included, the problem was solved.

<script>
window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
</script>

Funnily enough, I spent hours looking for a solution to this before posting this question. A solution then presented itself minutes later. Such is the life of the developer!

Upvotes: 1

Related Questions