Closed willbryant closed 2 years ago
Also getting some exceptions like this:
RequestOtherException: request failed (OS Error: Software caused connection abort, errno = 103)
Note there's no "SocketException:" at the start of the bit in brackets - compare it to these ones:
RequestOtherException: request failed (SocketException: OS Error: Software caused connection abort, errno = 103, address = ps.pndsn.com, port = 46882)
RequestOtherException: request failed (SocketException: Read failed (OS Error: Software caused connection abort, errno = 103), address = ps.pndsn.com, port = 49218)
Same app version and Android version. No idea why that's coming through differently, but it's making it hard to match properly.
Hi there! Thanks again for such an extensive insight into the issues you report! It doesn't happen often that we get such detailed and in-depth issue reports. I really (really!) appreciate it!
So a little bit of history to explain existing diagnostics - during development and testing I've noticed that there are tons of different networking exceptions that the Dart SDK reports and it was hard to find and cover all matching cases. We decided to add some initial ones and hope that with time and people reporting issues we would extend this (so the whack-a-mole was kind of planned).
What we didn't expect is the sheer amount of different types of network failures that the system reports and no standardized way that Dart presents them to us, so clearly we need a better solution for this. What you've done in the last example is closer to what we could do.
Additionally, in your own code you can totally match exception classes using type system and type checks instead of string matching - that is actually faster and more reliable since you can just check if an exception is HttpException
or SocketException
and so on (and those actually have fields that you can further use). We couldn't do that directly in the SDK - as an SDK we are platform independent and when those diagnostics were written we were relying on an external networking library (dio
) to handle requests. Because of this we couldn't import exception class types from dart:io
because that would limit our ability to publish the code as JavaScript compatible. But in your own application code you can handle that easier so I think its totally feasible and worthwile for you to just check for class types instead.
About the second part - I have no idea why those exceptions are sometimes "wrapped" - I assume this is because of how the underlying system tries to handle those exceptions - in some cases it may try to resolve it on its own without passing the exception up but it still fails so it wraps it and propagates further - no idea. In any case, matching by class should be enough to solve this part of the issue!
Let me know if you have any further questions. I'm going to leave this issue open and pin it so other people can take a look at this, report more exception types. I'm also adding it to feature requests so we can handle those exceptions better by default.
Thanks again!
@willbryant this issue is addressed in v4.0.0
As per #63 unhandled exceptions are a pretty significant problem right now, so we've been trying to identify and add diagnostics for all the errors we see in production. It's common for us because our app is used for deliveries and drivers regularly experience temporary comms problems as they go around, particularly in less populated hilly areas.
Happily the library allows us to extend the built-in detection. But, I think everyone is going to have the same problems as us, so I'd like to suggest a much broader set of diagnostics.
Hoping that you would upstream them later, we started out by extending the list of exceptions using exactly the same exact-match methodology as the library itself, a bit like these ones:
This looked like this:
Already you can see the list is getting pretty large. But in prod we found that we were getting many of the same errors all over again - except that they had different OS errno codes.
This is because Android runs on a Linux-derived kernel and iOS on a Darwin-derived kernel. These two have both used the BSD error constants but the values are different. So I started out by adding the two variants:
But in general, these are compile-time constants, but are not portable across operating systems. IMHO it makes no sense to hardcode them. I think there's no need to bring this in, so I suggest moving to this style:
But although incrementally better, I think this is still an unsustainable approach, for a few reasons:
So, long story short, I don't think it makes sense to keep playing whack-a-mole and coding in these detailed exception strings.
Is there any reason not to just capture all SocketException, HttpException, and HandshakeException errors and diagnose them all as temporary?
Something like this:
Perhaps even use normal exception class tests instead of string matching?