Forking from Electron process fails on Windows only from installed executable

754 views Asked by At

I'm developing a desktop application using Electron. I do certain tasks in a separate process to avoid locking renderer processes. I achieve this by calling require('child_process').fork. This works as expected on all platforms (linux, windows, osx). However when I package the app using electron-builder and install the generated NSIS installer and execute installed binary, the fork fails. I've launched this binary from command line in order to see any error outputs, but that hasn't helped. The parent process that forks the child process gets exit callback with exit code 1 when this happens. This is only the problem with the executable installed by the NSIS installer. If I run the electron-builder with --dir options and run the executable from the unpacked directory it works fine.

This led me to believe that it has to do with the permissions set on the executable by the installer. I've played around with the permissions, but without any success. I'm not sure which permissions are responsible for allowing/preventing this behavior.

Here's a screenshot of the permissions on the failing executable enter image description here

1

There are 1 answers

0
Jayesh On BEST ANSWER

I figured out the issue. It didn't have to do with executable file permissions or asar packaging.

To the best of my understanding, the problem was the way I was packaging a native module. The forked process is loading a native module. But while packaging I only chose to package the build/ directory, to avoid distributing proprietory source code. This was causing the failure of the forked process. When I also started packaging the package.json file of the native module alongside the build/ directory, the forked process ran correctly.