electron-reloader icon indicating copy to clipboard operation
electron-reloader copied to clipboard

Apparently Window Closes when I edit Main Electron File

Open deadcoder0904 opened this issue 6 years ago • 8 comments

Issuehunt badges

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.

deadcoder0904 avatar Feb 04 '18 20:02 deadcoder0904

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.

sindresorhus avatar Feb 05 '18 03:02 sindresorhus

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.

deadcoder0904 avatar Feb 05 '18 07:02 deadcoder0904

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!

1nv1n avatar Oct 03 '18 22:10 1nv1n

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

Lokua avatar Jan 03 '19 10:01 Lokua

@issuehunt has funded $40.00 to this issue.


IssueHuntBot avatar Mar 21 '19 08:03 IssueHuntBot

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.

catdad avatar Mar 21 '19 20:03 catdad

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).

j0hnm4r5 avatar Dec 04 '19 16:12 j0hnm4r5

https://www.youtube.com/watch?v=b-ATD74MQkw

MegaJSDeveloper avatar Dec 17 '19 00:12 MegaJSDeveloper