-
Notifications
You must be signed in to change notification settings - Fork 36
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
Improving error/exception handling #15
Comments
I guess it has to do with my lack of understanding on how to properly handle errors. https://dart.dev/guides/libraries/futures-error-handling. It is now clear, that we need to improve in this direction. |
Thank you for the quick reply! One more tiny example to mention. For pubSub.listen() scenario, it would be nicer to capture the errors (e.g. Redis connection breaks) with
|
I'll chime in here with some unsolicited observations. :) I've only looked through this code briefly so I might be totally off base but here's what I noticed: Starting here: https://github.com/ra1u/redis-dart/blob/master/lib/pubsub.dart#L15 The |
What is expected behavior if Current naive implementations, throws this up to connection opener, so it has consequence of dropped connection. What to do if redis server sends response we are unable to receive for some reason? Do we propagate error and then resume receiving further requests, like nothing happened? I think there are two kinds of issues. When user exception throws (like DatabaseReceivedValueIsTooLargeTo Process or UserCredentialsInvalid) we need to correctly propagate this trough this stack, and this is something that is possible to recover, since connection and protocol is unaffected. RedisConnection/protocol errors that happens less frequently is something that is probably impossible to recover from and best we can do is to notify that non recoverable error occurred. Dart has similar approach using Errors
and Exception
So maybe we should use Errors in our code to distinguish them from user kind of Exceptions. |
I think the above makes A LOT of sense! I think throwing an exception or error at the connection opener or constructor isn't a great since it's hard to catch those (like you'd have to wrap a constructor in a new zone to trap an error). You could provide an error call back in the constructor but as a consumer I'd rather get my exception or error at the point of use, then my application can take the appropriate action then. The commit above looks good, it doesn't include a fix for the OP's pubsub issue specifically but it could be easily extended address that. My only comment would be it would be nice if the |
@yeplato can you rerun test against recent master branch and report how it behaves regarding this reported issue. I am looking forward to close this. |
Fixed in version 3.1.0. Please do test and DO REPORT issue if you still find one. |
We are using your redis-dart in our server. Really appreciate your work!
We suggest that the error/exception handling may be improved a little bit.
In short, when we do
try{ await cmd.send_object( )}
ortry{ pubSub.subscribe()}
, we may expect that we can easily capture all underlying errors/exceptions (no unhandled exception to crash the server). However, we found that the only way to capture all errors/exceptions are adding runZoned() to wrapperconn.connect()
orPubSub(cmd)
, which makes the upper-layer logic not every easy to organize.Maybe registering stream error handlers from original socket across all underlying streams (e.g. lazystream) are a possible solution for this improvement?
The code snippets below are explaining the issue in details.
The text was updated successfully, but these errors were encountered: