Spawn updated Atom immediately instead of waiting for will-quit event

Spawning the new version of Atom within a `will-quit` handler would 
cause Electron to quit before having a chance to actually run the 
executable.

There may still be a possibility of raciness between closing the old 
version of Atom and opening the new one, causing resource contention 
between the two processes (e.g., IndexedDb) or failing to spawn the new 
process before the previous one quits. Addressing such raciness 
perfectly would require a much more complex solution and this approach 
is working for us consistently in our tests.

Co-Authored-By: Nathan Sobo <nathan@github.com>
This commit is contained in:
Antonio Scandurra 2019-06-25 15:47:33 +02:00
parent 28a17d7b41
commit 466a1ff18a

View File

@ -165,9 +165,7 @@ exports.restartAtom = app => {
const { projectPath } = global.atomApplication.lastFocusedWindow;
if (projectPath) args = [projectPath];
}
app.once('will-quit', () =>
Spawner.spawn(path.join(binFolder, 'atom.cmd'), args)
);
Spawner.spawn(path.join(binFolder, 'atom.cmd'), args);
app.quit();
};