theia: [electron] Backend processes are already terminated before 'will-prevent-unload' is called
Bug Description:
Start the app, make an editor dirty or set the application.confirmExit to true. Terminate the app with Ctrl/Cmd+Q on macOS, you get the Any unsaved changes will not be saved. dialog, but the BE has already terminated so hitting No in the dialog will result in an offline app.
We need to figure out the followings:
- ~is it a macOS issue only?~ It is not a macOS only problem. Same bug on Windows when quitting the app with
Alt+F4. See here. - ~was there a change in electron 9.x?~ It is not related to electron 9.x. See here
- is it related? ~Maybe; see here.~ Most likely not: https://github.com/eclipse-theia/theia/issues/8186#issuecomment-659415028
- should we switch back to this?
Mentioning @marechal-p, @mcgordonite here. If you have any idea what’s causing it, please let me know.
Steps to Reproduce:
Additional Information
- Operating System:
- Theia Version:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (20 by maintainers)
Hi, sorry to open up a closed issue, however on
masterI’m still encountering the bug where confirming the exit does not work properly on Electron (it appears to working fine in the Browser version). When prompted with the “Are you sure you want to quit?” dialog, hitting “No” immediately closes the application. This is particularly worrisome because now it will exit the application without allowing the user to recover their work, whereas before it would kill the backend process but there was at least an opportunity to copy over the work that was unsaved.To reproduce (I’m running this on RHEL7):
masterThe odd part about this is if you open the DevTools and then do the above steps, everything works as expected (this might be why when testing it slipped through the cracks).
Any thoughts @kittaakos @marechal-p ?
I’d be happy to open up a new ticket if you’d prefer that instead.
@zhaomenghuan OK,I’ will have a try and give you feedback then.
@kittaakos I tried to comment out the beforeunload event in the FrontendApplication class. At this time, if the modified file is not saved and clicked to exit, the front end will not be disconnected. I guess this problem is related to the code here.
In addition, clicking the yes button did not exit normally, and I feel that the logic is not right.Looks like a bug in electron, please see here: https://github.com/electron/electron/issues/24994
Putting this back to
unloadseems to fix it: https://github.com/eclipse-theia/theia/commit/d7f7c90376e3660f15149a2de8286d8d2b015c75#diff-b3c47e20ff0569909accc8030cc40ea8R164I think there would be consequences to making that change though.