electron-reloader
electron-reloader copied to clipboard
Apparently Window Closes when I edit Main Electron File
I just added console.log('its not working')
to index.js
& app stopped. index.html
works.
There is a $40.00 open bounty on this issue. Add more on Issuehunt.
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on Issuehunt to raise funds.
From the top of the readme:
When files used in the main process are changed, the app is restarted, and when files used in the browser window are changed, the page is reloaded.
Ohh so this is just a replacement for Refresh❓
When files used in the main process are changed, the app is restarted, and when files used in the browser window are changed, the page is reloaded.
I still don't understand this bcz my terminal stops but the app is still running & AFAIK when terminal stops app also closes when this package is not used.
Hey @sindresorhus, first off; thanks for the package! Adding my comment/question here since it's somewhat related to the issue opened. I just initialized a new app using electron-forge & added electron-reloader.
I've included require('electron-reloader')(module);
in a try-catch
& if I make a change on main.js
, the app restarts - but I end up with two windows. Make another change & now I have 3 windows.
It wasn't completely clear from the README
whether this is expected (I would expect not), but wanted to check with you.
Thanks!
I was also a bit confused as even though editing main.js does restart the app, it also exits the original process so you're left without terminal. I tried to patch around the source code but didn't get far, so decided to add my main process files to electron-reloader ignore
option, and am using the following script to start the app. Perhaps others coming across this will find it helpful (you'll probably want to adjust the args to spawn
to reflect your needs):
https://gist.github.com/Lokua/b88ffc4aa32398abe3cf8688444799ac
@issuehunt has funded $40.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
This issue is inherent to how Electron works (at least on Windows). When an electron app is launched, it will create a new process group, separate from the command line process. When you app.relaunch()
, it will in fact launch a second instance of the app when the first one exits. Anything running in-process inside the electron app won't have any control over the reuse of stdio, which is why this and all the other in-process live reloaders have this issue. Without digging into the electron source code itself to figure out if electron can be changed to allow for better restarts, the best way I have found to deal with this issue is using an out-of-process manager like electronmon
.
On MacOS, I'm hitting pretty much the same issue; on reload the terminal process exits and the app closes, then the app reopens (but the terminal process does not reconnect, leaving me with no console logs).
https://www.youtube.com/watch?v=b-ATD74MQkw