From: Luke Lau Date: Thu, 14 May 2020 20:18:13 +0000 (+0100) Subject: Fix listener thread listening after the server process was stopped X-Git-Tag: 0.11.0.0~1 X-Git-Url: https://git.lukelau.me/?p=lsp-test.git;a=commitdiff_plain;h=133940df94b1e8745598699a492e5c9534644d75 Fix listener thread listening after the server process was stopped Therefore fixes hGetLine: illegal operation (handle is closed) exceptions, because the handles were being closed whilst the listener thread was still reading from them. Fixes #66 --- diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index 56e206d..9076a8e 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -267,7 +267,9 @@ runSessionWithHandles serverIn serverOut serverProc serverHandler config caps ro serverAndListenerFinalizer tid = do finally (timeout (messageTimeout config * 1^6) (runSession' exitServer)) - (cleanupProcess server >> killThread tid) + -- Make sure to kill the listener first, before closing + -- handles etc via cleanupProcess + (killThread tid >> cleanupProcess server) (result, _) <- bracket serverListenerLauncher serverAndListenerFinalizer