Skip to content

Commit d9c3f48

Browse files
authored
Avoid server crash when handler returns LspResult.Error (#33)
It appears that #29 broke the reporting of LspResult.Error to StreamJsonRpc. StreamJsonRpc processes LocalRpcException to report exceptions/errors from request handlers. In particular we have code in `requestHandling` that actually throws LocalRcpException when handler returns LspResult.Error. This commit adds code to skip markingLocalRcpException as a fatal exception and make it not crash the server.
1 parent b145255 commit d9c3f48

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/LanguageServerProtocol.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ module Server =
9090
// and thus any exception that happens during e.g. text sync gets swallowed.
9191
use jsonRpc =
9292
{ new JsonRpc(jsonRpcHandler) with
93-
member this.IsFatalException(ex: Exception) = true }
93+
member this.IsFatalException(ex: Exception) =
94+
match ex with
95+
| :? LocalRpcException -> false
96+
| _ -> true
97+
}
9498

9599
/// When the server wants to send a notification to the client
96100
let sendServerNotification (rpcMethod: string) (notificationObj: obj) : AsyncLspResult<unit> =

0 commit comments

Comments
 (0)