Skip to content

Commit 0641128

Browse files
committed
Server.fs: don't crash the server when handler crashes
Previous commit on this apparently didn't do the job right. Related: - #44
1 parent 90be453 commit 0641128

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## [Unreleased]
7+
8+
* Fix an issue intermittent server crashing after upgrading to latest Ionide.LanguageServerProtocol;
9+
610
## [0.5.4] - 2022-08-20 / Šilavotas
711
https://www.lrytas.lt/kultura/istorija/2021/08/07/news/kitoks-kaimas-prienu-rajone-kurio-neisdraske-net-sovietu-valdzia-bendruomenes-nariais-tampa-ir-kaunieciai-20347142
812
* Upgrade roslyn libs to 4.4.0-1.final;

src/CSharpLanguageServer/Server.fs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,15 +1008,17 @@ let setupServerHandlers options (lspClient: LspClient) =
10081008

10091009
try
10101010
let scope = ServerRequestScope(state, stateActor.Post, logMessage)
1011-
try
1012-
return! asyncFn scope param
1013-
with
1014-
| ex ->
1015-
let unpackedEx = ex |> unpackException
1016-
if (unpackedEx :? TaskCanceledException) || (unpackedEx :? OperationCanceledException) then
1017-
return LspResult.requestCancelled
1018-
else
1019-
return LspResult.internalError (string ex)
1011+
1012+
let! resultOrExn = (asyncFn scope param) |> Async.Catch
1013+
1014+
return
1015+
match resultOrExn with
1016+
| Choice1Of2 result -> result
1017+
| Choice2Of2 exn ->
1018+
match exn with
1019+
| :? TaskCanceledException -> LspResult.requestCancelled
1020+
| :? OperationCanceledException -> LspResult.requestCancelled
1021+
| _ -> LspResult.internalError (string exn)
10201022
finally
10211023
stateActor.Post(FinishRequest requestId)
10221024
}

0 commit comments

Comments
 (0)