Ignore SessionException during test cleanup from listener thread#637
Closed
crtschin wants to merge 1 commit into
Closed
Ignore SessionException during test cleanup from listener thread#637crtschin wants to merge 1 commit into
SessionException during test cleanup from listener thread#637crtschin wants to merge 1 commit into
Conversation
SessionException during cleanupSessionException during test cleanup from listener thread
Author
Just had an idea, |
Author
|
Nevermind, can't locally reproduce this with my change in haskell/haskell-language-server#4886. |
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.
Follows haskell/haskell-language-server#4884 (comment).
I get quite a few flaky errors when running HLS's
ghcide-teststestsuite.The following is a small investigation into why. This piece of code is the failing bit. We create pipes and pass these to both
ghcideandlsp-testfor communication. Tests then intermittently fail with the following error:Test Failure
Leading me to
lsp-test'sgetHeaders, called when it tries to read from the pipe. Now, I spent quite a bit trying to track down why the handle was closed, but couldn't find anything definitive. The onlyhClosein this codepath is this one that occurs after the test is done.Taking a defensive view and accepting that the pipe can be broken, leads to the question when it is acceptable that the pipe can be broken. I think that bit is here.
lsp/lsp-test/src/Language/LSP/Test/Session.hs
Lines 319 to 322 in 2d2c468
When the server test session is done, and we're cleaning up the communication threads. The error handler in the listener thread can still throw the EOF error to the main thread though, interrupting the main thread that's doing the gentle shutdown of the language server.
Short aside on the cleanup
I was severely confused why that
finallywas there in the shutdown code. After all, it's in theafterblock of abracket. It should always be ran already asmaskis on. Even better, this huge comment ontimeout, gives that timeout uses async exceptions to do it's thing, which in a masked setting means that the timeout is deferred until the masking state is dropped.What I missed is (as always) interruptibility. During interruptible functions, i.e. blocking functions on
MVar, async exceptions can occur so thefinallyis still relevant.The change in this PR stops the tests from being flaky (I can run the suite 100x without failures, which would have otherwise occurred within 1-5 runs).