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
RFC: Make JsonRpc to NOT swallow exceptions #29
Conversation
This is once again a continuation of ionide#25. There were several issues with the previous version. Catching exceptions in server's code and turning them into LocalRpcExceptions probably isn't the best because: 1. Notifications don't require a response, hence no error will be shown to the user. Effectively, this means any exceptions including fatal can get swallowed. 2. The context of the original exception is lost in conversion.
As an example, with this change I'm getting an error and a stack trace like this in lsp logs, when the server hits
|
Whereas before that same error would be transmitted to the client and just show the exception message? |
Well overall I'd prefer to have the information, so let's take this change :) |
Coolio! 🤘 As I see it, the only questionable part in this PR is: use jsonRpc =
{ new JsonRpc(jsonRpcHandler) with
member this.IsFatalException(ex: Exception) = true } In case dying on exceptions will prove to be no bueno, we could make this thing configurable. |
It appears that ionide#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.
uh.. there are actually some problems with this, regarding handling of LspResult.Error -- see #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.
This is once again a continuation of #25.
There were several issues with the previous version.
Catching exceptions in server's code and turning them into LocalRpcExceptions probably isn't the best because:
to the user. Effectively, this means any exceptions including fatal
can get swallowed.
This is a breaking change and may not be desirable for servers that use exception for control flow/recovery. But I think the spirit of the library is such that
LspResult
'sError
.Note: since now we're awaiting
jsonRpc.Completion
which completes when connection is closed, I could clean up a workaround for VSCode's incorrect shutdown sequence.