Skip to content

Commit

Permalink
fix exit logic when the window is already destroyed (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartolomej authored Dec 13, 2022
1 parent b1bbdfd commit 3a6e53f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frontend/src/targets/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,18 @@ app.on("before-quit", async function (e) {
// Prevent app termination before cleanup is done
e.preventDefault();
try {
// Notify renderer process
win.webContents.send("exit");
// On macOS the user could first close the app by clicking on "X"
// (which would destroy the window) and later quit the app from app bar.
// If we trigger any method on destroyed window, electron throws an error.
if (!win.isDestroyed()) {
// Notify renderer process
win.webContents.send("exit");
}

await backend.cleanupAndStop();
} catch (e) {
dialog.showMessageBox({
message: `Couldn't shutdown successfully. Some flow processes may be still running in the background.`,
message: `Couldn't shutdown successfully: ${String(e)}`,
type: "error",
});
} finally {
Expand Down

0 comments on commit 3a6e53f

Please sign in to comment.