We wrote an Electron app that works flawlessly on both mac and windows. Everyone is super happy (the mac was a bonus, windows was the real target).
Then the client brings up a requirement that entails running the app in “headless mode”. Basically a single function of the app should run periodically in the background regardless of whether the app is open or not.
Shouldn’t be too hard we think, just use process.argv to figure out which mode the app should run in and setup a cronjob on the mac and a scheduled task on windows.
And that’s where things start falling over. It works flawlessly on the mac, the browser window is not invoked, the background function is called ( entails a series of network calls and some business logic ) and ends up calling app.quit().
On windows however the background function is only able to make a single network call, the callback then just hangs on the following network call. The only way to get it to run to completion is to invoke a browser window which is obviously not an option for a background service. I assume that the event loop on windows is dependent on the browser window or something?
So it looks like we will have to resort to .NET. Horrible times, Electron was so much fun!
Since Electron was not created with this in mind I can’t really complain or file a bug or anything. But I thought it might be beneficial to have this written up somewhere - maybe there’s a workaround we’re not seeing - maybe this saves some other poor fool from following in our footsteps.
All the best and here’s hoping we get to play with Electron again soon.