Skip to content

Commit

Permalink
fixed timeout teardown for electron context (#357)
Browse files Browse the repository at this point in the history
* fixed timeout teardown for electron context

* exit code 1 in case of teardown timeout

* electron graceful shutdown on teardown timeout
  • Loading branch information
rafapaezbas authored Oct 17, 2024
1 parent c05c205 commit c397985
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gui/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ class App {
}
})

electron.app.on('app-exit', () => {
electron.app.exit()
})

const { state } = this

this.starting = this.ipc.start({
Expand Down
7 changes: 6 additions & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ class API {
await Promise.race([this.#teardowns, countdown])
if (timedout) {
console.error(`Max teardown wait reached after ${MAX_TEARDOWN_WAIT} ms. Exiting...`)
Bare.exit()
if (global.Bare) {
Bare.exit()
} else {
const electron = require('electron')
electron.ipcRenderer.send('app-exit') // graceful electron shutdown
}
}
}

Expand Down

0 comments on commit c397985

Please sign in to comment.