electron: Problem when spawning process from node with IPC enabled with electron >v2

  • Electron Version (output of node_modules/.bin/electron --version): 3.x , 4.x
  • Operating System (Platform and Version): Ubuntu 16.04 x64, Ubuntu 18.04 x64
  • Last known working Electron version (if applicable): 2.x (latest works)

Expected Behavior

Spawning packaged electron apps from node like so:

let child = childProc.spawn('./path/to/electron-executable', [], {
  stdio: [0, 1, 2, 'ipc'] // note presence of last 'ipc' flag
});

Should work as normal, but enable process.send()ing data to the app that spawns it from within the node process.

Actual behavior

With electron major versions higher than 2, the browser windows that are spawned don’t load properly if the IPC flag is set. If the IPC flag is not set, everything works as normal.

To Reproduce

  1. Clone my issue reproduction repo
  2. git checkout packaged-ipc-test
  3. npm i
  4. npm run package
  5. npm run launch-from-node

You’ll see that the app is launched, but the Browser Window it launches never loads. If you downgrade electrion to 2.x it’ll all work properly. If you remove the 'ipc' flag from launch-from-node.js:5 then the browserwindows load properly but there’s no IPC with the parent process.

Remember to re-package with any change to the electron app - this has caught me out a few times now!

Screenshots

Launching packaged electron app from node with 'ipc' flag: blank app window

Additional Information

Appreciate this is possibly an unusual use-case, but the IPC is critical for my application (we need to be able to detect if it crashes and re-launch).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15

Most upvoted comments

Dear core maintainers, do you have an exact plan to fix this ipc-related problem? This problem seriously affects our operation in CI environments such as Linux.

@rlidwka @ckerr @zcbenz @MarshallOfSound

can anybody take a look at this issue?

cc @zcbenz @groundwater

Yes, I was able to reproduce this as well (ubuntu 18, node.js 8.10).

As a side note, same exact issue happens when using navit, here is how electron is launched in that package, which works with electron@2 but fails with electron@4 (shows blank white screen, nothing ever loads).

It looks like this is fixed in version 5. I checked the example on several computers (win7 x64, win8 x86, win10 x64) with an electron 5.0.2 and it worked correctly. I haven’t tried it on Linux, but it probably will be fine there.

UPD: I confirm, it works for me on ubuntu 16 too