Handling exceptions in IDE main to avoid entering "zombie process" state. (#3648)

This is meant to address https://www.pivotaltracker.com/story/show/182691027.
This commit is contained in:
Michał Wawrzyniec Urbańczyk 2022-08-16 14:56:08 +02:00 committed by GitHub
parent 0dbbbaad00
commit 6c82588972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 18 deletions

View File

@ -54,6 +54,9 @@
methods, atoms and functions are presented in nice, categorized view. The most
popular tools are available at hand. The The panel is unstable, and thus is
available under the `--enable-new-component-browser` flag.
- [Fixed error handling during startup.][3648] This prevents entering IDE into a
"zombie" state, where processes were started but not visible to user. They
could cause issues with starting further IDE instances.
#### EnsoGL (rendering engine)
@ -273,6 +276,7 @@
[3601]: https://github.com/enso-org/enso/pull/3601
[3617]: https://github.com/enso-org/enso/pull/3617
[3629]: https://github.com/enso-org/enso/pull/3629
[3648]: https://github.com/enso-org/enso/pull/3648
#### Enso Compiler

View File

@ -476,7 +476,10 @@ let mainWindow = null
let origin = null
async function main(args) {
// Note [Main error handling]
try {
runBackend()
console.log('Starting the IDE service.')
if (args.server !== false) {
let serverCfg = Object.assign({}, args)
@ -495,7 +498,23 @@ async function main(args) {
}
})
}
} catch (err) {
// Note [Main error handling]
console.error('Failed to setup IDE. Error:', err)
Electron.app.quit()
}
}
// Note [Main error handling]
// ==========================
// It is critical that the main function runs in its entirety. Otherwise, IDE enters a "zombie
// process" state, where Electron processes have been spawned, but there is no window and user can't
// observe anything. Usually they will try to spawn another instance of the IDE, but this can fail
// because of these zombie process presence.
//
// The solution is to catch all errors and exit the process if any part of the initial setup fails.
// If it succeeds, at least the Window will be shown, allowing the user to observe the error and
// close it.
function urlParamsFromObject(obj) {
let params = []