Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard resets result in spawning two electron processes #46

Closed
mihaiconstantin opened this issue Mar 10, 2018 · 3 comments · Fixed by #48
Closed

Hard resets result in spawning two electron processes #46

mihaiconstantin opened this issue Mar 10, 2018 · 3 comments · Fixed by #48

Comments

@mihaiconstantin
Copy link

mihaiconstantin commented Mar 10, 2018

Thanks for this awesome package!

I noticed that any hard reset results in spawning two electron processes. Here are the steps to reproduce it:

  1. Preparing the workplace:
git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install
npm install --save-dev electron-reload
  1. Enabling electron-reload by adding the following to the main.js file:
require('electron-reload')(__dirname, {
     electron: require(`${__dirname}/node_modules/electron`)
});
  1. Triggering the issue:

    • change the height property of the mainWindow (e.g., from 600 to 300)
  2. The issue per see:

    • the window is closed and a new window is created, but, if you move it to a different position on your screen you will notice that another window has been created.
    • also, any subsequent edits result in the same behavior.

I am currently using Windows 10, (Build 16299.248) and to run the scripts above I used cmder_mini (i.e., but I doubt this matters).

Do you have any clues how to tackle this?


Edit: I am aware that in the README you indicate the use of hardResetMethod: 'exit' to prevent spawning multiple instances, but in this case, the following did not make a difference:

require('electron-reload')(__dirname, {
     electron: require(`${__dirname}/node_modules/electron`),
     hardResetMethod: 'exit'
});
@yan-foto
Copy link
Owner

We had a similar issue in #9 but it was actually fixed. Unfortunately I have no experience with Windows OS and could only help with Linux/MacOS related issues. I will keep this issue open, until we have a solution. Sorry about that :(

@mihaiconstantin
Copy link
Author

Thanks for responding. I will try to take a closer look and see if I can understand what exactly happens. Will write back if I find anything useful. No need to be sorry---this is a cool project.

@ghost
Copy link

ghost commented Apr 1, 2018

I encountered same issue and traced the cause.

At change event for the main script file is fired, electron-reload spawns electron process and calls app.quit() (or app.exit()).
app.quit() does exiting the main process after all BrowserWindows were completely closed.
So there is a possibility of firing change event again after calling it.

For example:

  • The editor makes change twice.
  • Due to chokidar's (or fs.watch's) bug. There are many reports related to it.

A solution to that is ignoring multiple change events for the main script file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants