-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
electron: fix killing backend #8809
Conversation
I think ignoring the error is enough. We do it for the plug-ins too: theia/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts Lines 138 to 140 in 0a72196
|
Please swallow the error with From the docs:
Please change. Thank you! |
My change currently checks that the process is running before trying to kill it (avoiding the ESRCH when the process was already dead). If the process cannot be killed despite that I think an error is ok? |
I do not want to accept this PR as is because I am not convinced, it is safe. There could be false negative checks. For example, there was an error, but the backend process is still up and running. (Here it is in your code.) In such cases, we do not terminate the backend process on the app quit although we should. There are applications out there building on top of Theia's behavior, and I am not positive that the proposed change covers all cases. Why do not we just swallow the |
408df5c
to
b25d439
Compare
I wanted to avoid
The implication is that if we allow killing when we somewhat expect to get I added the check as requested. |
Good catch, maybe we have to change it for other places in Theia.
Much appreciated. Why do not we do just this and nothing more? (I think, you forgot to rethrow the error, so you swallow everything. This is one of the main reasons I try to go for minimum changeset.) try {
// If we forked the process for the clusters, we need to manually terminate it.
// See: https://github.com/eclipse-theia/theia/issues/835
process.kill(backendProcess.pid);
} catch (error) {
// If the process wasn't already running then do nothing.
// See https://man7.org/linux/man-pages/man2/kill.2.html#ERRORS
if (error.code === 'ESRCH') {
return;
}
throw error;
} |
b25d439
to
49f3806
Compare
Good catch I was missing the re-throw. I'd keep the rest to address what I talked about earlier. |
Because I'm focusing on the Electron backend case. But I agree that it might be something to apply elsewhere too. This could be a follow up. |
OK. Thanks for the update. 👍 I verify it soon.
Can you please explain?
For clarification: as you might have noticed, I am trying to push for minimal changesets and avoid unnecessary changes. Currently, there is no way to verify any proposed change in a bundled electron app built from the sources as part of the review process. There are applications out there using Theia as a framework, and I want to ensure consistency in the core behavior for them. |
I don't think anything is unnecessary in the current changes. If we know the backend died, there's no use issuing a kill signal: this is what I minimally implemented. Regarding the follow up I mentioned, I thought you said that if I address the issue of trying to issue a kill when the process is not running, then we should do it in other places where we kill processes. I answered that this change only focuses on this specific location, and other places can be looked into in a different PR. I might have misunderstood your question, I now see what you meant. |
49f3806
to
bb8a659
Compare
Gracefully kill the backend process when exiting an Electron app. A check is made to make sure we only kill the backend if it is running. The risk else is that we could kill a random process with the same PID as the backend had before exiting. This should have been rare but not impossible. Signed-off-by: Paul <paul.marechal@ericsson.com>
bb8a659
to
9fd46af
Compare
@kittaakos I managed to trim the change to be more minimal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works. Thank you!
Gracefully kill the backend process when exiting an Electron app. A
check is made to make sure we only kill the backend if it is running.
The risk else is that we could kill a random process with the same PID
as the backend had before exiting. This should have been rare but not
impossible.
Signed-off-by: Paul paul.marechal@ericsson.com
Closes #8804
Closes #8534
How to test
Review checklist
Reminder for reviewers