-
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
Execute app shutdown vetoes in sequence #10861
Conversation
The motivation for running the actions in parallel is that it's possible for an action to resolve itself without any user intervention (e.g. terminals need to check whether there are running processes in the terminals, which is asynch but may end up finding none). In that case, running several such actions in sequence would only delay shutdown. Is there a definite reason for wanting to run the actions sequentially? |
I liked the parallel approach initially as well, however I noticed one issue in particular with it: When we have multiple The reproduction/testing steps show this issue fairly well with the base app. This becomes more exaggerated in downstream Theia apps, where there are more conditions which might prevent the app from shutting down gracefully. |
Ah - that clarifies the problem for me. It definitely makes sense to bail after the first rejected option. Your code definitely does that - let me think a moment about other possibilities. |
The current implementation was influenced by VSCode's, and VSCode has the same problem: if you have two vetoes with dialogs (e.g. dirty file and terminal), canceling one doesn't stop the next one from appearing. I don't really see an alternative to running in sequence if we want to avoid showing meaningless dialogs. |
@colin-grant-work I have an idea which should at least alleviate the issue of "data that needs some time to be prepared". What if we change the interface OnWillStopAction<T = undefined> {
reason: string
priority?: number
prepare?(): MaybePromise<T>
action(prepared: T): MaybePromise<boolean>
} We could run |
@msujew, I think I like it :-). |
06ef72c
to
1dfd87a
Compare
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.
This looks good to me. It should not break any implementations oriented to the older behavior, but it does provide flexibility and cancel any irrelevant dialogues.
What it does
Closes #10860
Since we prioritize actions anyway, it didn't make a lot of sense to execute the actions in parallel. For example, if we have the following two
OnWillStop
results, the second one returns first, even though its priority is lower:How to test
false
will prevent execution of subsequent actionsReview checklist
Reminder for reviewers