-
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
Fix unhandled promise rejection during git operations #12433
Fix unhandled promise rejection during git operations #12433
Conversation
…om the op callback
@erezmus wondering why this would crash the container on Kubernetes. I have a hard time to imagine why that would be the case. |
@tsmaeder not sure why it happened in our cluster but after applying that patch in our theia fork, it fixed the problem 🤷 |
@@ -30,7 +30,7 @@ export class GitRepositoryManager { | |||
|
|||
run<T>(repository: Repository, op: () => Promise<T>): Promise<T> { | |||
const result = op(); | |||
result.then(() => this.sync(repository)); | |||
result.then(() => this.sync(repository)).catch(e => console.log(e)); |
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.
Only the sync
is actually unhandled, whereas the op()
call is handled at a higher level. If we use a catch-all mechanism here, we potentially swallow errors that should be thrown and caught on the caller site. We should only call catch
on the sync
promise:
result.then(() => this.sync(repository)).catch(e => console.log(e)); | |
result.then(() => this.sync(repository).catch(e => console.log(e))); |
@erezmus Are you still interested in contributing the fix? I have an outstanding comment that I would like to see addressed before we can merge this. If there's no further feedback, I would close the PR in the next few days. |
@msujew i'll try to have a look today or tomorrow, otherwise next week |
@msujew I've had a test both on theia and ksc with your adopted change, looks good |
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.
Awesome, looks good to me as well 👍
What it does
This fixes an issue we've seen happening on KSC when there's a conflict while pulling git changes from a remote.
It seems that when exception is thrown from the dugite-git library, an unhandled promise rejection is caught by the 'unhandledRejection' handler which rethrows the error and ends up in the 'uncaughtException' handler, which caused the container to crash on kubernetes. On a local docker compose setup, the container doesn't crash.
How to test
Review checklist
Reminder for reviewers