Packaged Electron app on Mac spawns a new copy of itself on startup


I made an app with Electron (my first!) for Windows, Mac and Linux. It uses Process Manager (pm2) and a task bar icon. It works on Linux and Mac. I have not tried it yet on Windows. I packaged it on Mac and something undesired happens: the application starts itself to infinity. I added this to the main script: app.makeSingleInstance(() => { app.exit(2); }); just to temporarily contain the problem. Now, each instances starts a new instance and closes. Eventually, the whole loop crashes.

The problem is not present in the non-packaged version of the app. I’m not sure what to share in order to reproduce the problem. Is this some common issue that seems obvious to more experienced Electron devs? Or will I need to start digging all day?