Repository navigation
fix: keep the editor service responding while the config is resolved - #1347
Merged
Merged
Conversation
…block-loop # Conflicts: # crates/dprint/src/commands/editor/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The editor service resolved the configuration for a "can format" request (and for a format request when it had none yet) inside its message loop. Resolving the configuration can take a long time (ex. downloading and compiling plugins), and for that time the service didn't respond to anything: an "is alive" check went unanswered and a "cancel format" wasn't acted on.
Now the messages that need the configuration ("can format" and "format") are handled one at a time on a separate task from the one receiving messages. They're still handled in the order they arrive, so a format request still waits for a config check ahead of it and formats with the latest configuration.
A format request can also be cancelled while it's waiting to be handled, in which case it's skipped.
The test makes the plugin download hang and asserts an "is alive" check gets a response while the "can format" request is still waiting. It also cancels a waiting format request, though it can only observe that the service keeps working afterwards and not that the format was skipped.