-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Improve handling of unexpected errors #277
Comments
To be explicit about the error I'm facing, here is where Now, I could be mistaken, but I don't think there's much handling we can do here by default other than catching and dropping the error (the reasons for the error have already been logged by
I think you're right... and having the ability to register an error handler could be really useful. Certainly for I'm not sure however, how useful wrapping user features will be... I fairly sure issues in features are already caught by the existing error handling in |
So what we're saying is that
Oh, my understanding was that LSP's Yes I had an annoying test-hang bug the other day too! The main thing ended up being having to add a timeout in a subprocess call, so it wasn't either Pygls' or pytest-lsp's fault. But it did force me to better set up logging in the server, because of course, by default the client, which is the only thing pytest has access to, doesn't receive much in the way of feedback and logging from the server running in another thread. Anyway, wrapping |
Yes, everything winds up coming through this class at some point. If you're interested, messages come into
Not deeper... but we need another one to catch some errors in
🤦 you're right! My head is so deep in JSON-RPC land at the moment I forget about
Sounds good 😄 |
Ok great, thanks for the insights 🤓 So just to sketch things out:
Not saying you should do all that if you're the first in there. Just making a note for the future. |
Oh, wait! Hold the press! I've figured something out: errors in LSP requests and notifications are handled differently. So, the actual formal way to handle a LSP client request is with a LSP Now, here's the thing. LSP requests and notifications are 2 distinct things. You probably already knew that, but I've only just realised that now 😬 For anybody else that isn't aware of the difference, So, this changes gears a little. Unchanged is that we're still wanting to improve error handling for I've updated my previous comment to better reflect this new insight. |
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
Notable behaviour change: All errors outside of LSP requests are now sent to the client as `showMessage.type = MessageType.Error` messages. This may result in existing custom LSP servers showing errors that were not seen before, these aren't new errors, just previously undisplayed errors. `JsonRPCProtocol.data_receieved()` now catches unhandled errors. Fixes #277
This jumps off from an issue identified by @alcarney in the v1 breaking changes PR #273 (comment)
Pygls does already catch some errors, but not all. Nor does it offer a way for server authors to handle those unexpected errors.
@alcarney Is that a fair summarisation of the problem? Obviously the underlying message parsing problem needs to be fixed, but is it not a reflection of a deeper issue, that Pygls couldn't recover from that error?
Recently I've been attempting to build a Pygls template project, that offers a reasonable and informative starting point for new custom servers. Maybe it's my relative inexperience with Pygls, but I noticed that there doesn't seem to be a centralised point for all error handling? My naive approach is to decorate the
feature
decorator like so:Does that seem relevant to the deeper issue at hand?
The text was updated successfully, but these errors were encountered: