electron-userland / electron-userland/electron-webpack

Not shutting down correctly on Windows

Open
#87 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
902
Forks
168
PR merge metrics
No merged PRs in 30d

Description

I have a project that is (mostly) based on the quick start repo, but when I run it on Windows and close the main window, my command prompt leaves me with a stylized "Terminate batch job (Y/N)?" which keeps the process running. Eventually it will shut down on its own but it's not obvious that it will do that since it seems to be waiting for confirmation. This problem was not present when I was using Electron by itself.

This is my `src/main/index.js`:

```javascript
// @ts-check

import { app, BrowserWindow } from 'electron'
import url from 'url'
import path from 'path'

const isDevelopment = process.env.NODE_ENV !== 'production'

let mainWindow

function createMainWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 550,
autoHideMenuBar: true,
})

const url_ = isDevelopment ?
`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` :
url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
})

if (isDevelopment) {
mainWindow.webContents.openDevTools({ mode: "detach" })
}

mainWindow.loadURL(url_)

mainWindow.on('closed', () => {
mainWindow = null
})

mainWindow.webContents.on('devtools-opened', () => {
mainWindow.focus()
setImmediate(() => {
mainWindow.focus()
})
})
}

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (mainWindow === null) {
createMainWindow()
}
})

app.on('ready', createMainWindow)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the quick start project on Windows using the provided src/main/index.js and compare its shutdown behavior with Electron by itself. Start by tracing what happens after the window-all-closed and app.quit events; done means closing the main window exits cleanly without leaving a “Terminate batch job (Y/N)?” prompt.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript, webpack
Domain
build-system, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.