0

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.

Arc
  • 329
  • 3
  • 11

1 Answers1

1

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!

Arc
  • 329
  • 3
  • 11
  • 1
    in my case FWIW, I only had to delete window.module before loading jquery, after which I added it back to window. not sure if deleting require/exports is necessary – pushkin Mar 06 '20 at 22:10