-
Notifications
You must be signed in to change notification settings - Fork 97
Gracefully exit the server #622
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
Open
soulomoon
wants to merge
14
commits into
haskell:master
Choose a base branch
from
soulomoon:gracefullyexit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+107
−43
Conversation
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
- Catch and report broken pipe (resource vanished) when sending responses; log up to 400 chars of the outgoing message for context. - stop client sender after a shutdown response is sent.
Do you want a review on this yet? |
Yes, the this MR is ready for review, but the corresponding hls changes at haskell/haskell-language-server#4701 still need some more polishing. |
if startDelay and updateDelay are 0. It ensures that test cases relying on progress notifications to be sent are not flaky.
6ee37a0
to
3cf7ceb
Compare
|
This reverts commit 3cf7ceb.
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 main purpose of this patch is to fix the long standing broken pipe issue in hls, see haskell/haskell-language-server#1875. It accompanied with the hls fix haskell/haskell-language-server#4701
This pull request introduces several improvements to the LSP server's shutdown and exit handling. The changes ensure that output is properly flushed and errors are logged if the client disconnects unexpectedly, and that the server's sender thread is gracefully shut down. The shutdown and exit logic is now more explicit with new state tracking and barriers.
resExit
barrier toLanguageContextState
and anisExiting
function to track when the server should exit, ensuring that the server stops processing messages after an exit notification is received. [1]clientOut
to catch and logBrokenPipe
errors when sending output fails (e.g., if the client closes the output handle), including a truncated version of the outgoing message for debugging.withAsync
andrace
to better manage the sender thread lifecycle and ensure clean shutdowns. [1]sendServer
function to terminate after sending the shutdown response, preventing further messages from being sent after shutdown. Modified the main server loop and sender logic to wait for the sender thread to finish after shutdown, with a timeout and logging if it does not stop in time.summary generated by Copilot