-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
chore: adding errorListener #777
Conversation
Great idea. Very often such functionality is required |
@renefloor @Baseflow could you please take a look at this? :) |
cached_network_image_web: | ||
git: | ||
url: https://github.com/SuaMusica/flutter_cached_network_image.git | ||
ref: feature/errorListener | ||
path: cached_network_image_web |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not completely sure, but should this be included in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this to use the branch and compile.
When it's merged it should be removed
When is the merge planned? Looks critical for firebase crashalytics. |
Up |
Hi, @douglasiacovelli are you planning to merge this PR? |
To be honest I'm not the owner of this repo. I've just reviewed because I wasn't sure about the code itself :) |
@renefloor hey there! since it's been some months since this was opened, do you need any help releasing this fix? |
any updates after a year? |
Hi @renefloor - big fan of the lib. Would like to throw another plus 1 onto merging this. Currently, my handled image errors are blowing up my crash reporting (and stopping on breakpoints). This seems like a very reasonable solution and isn't too dissimilar to how Flutter's own
This will also solve numerous issues
|
Merge please. |
I don't expect this PR get merged soon, given that one of the maintainers doesn't consider this as an issue #336 (comment). @renefloor I kindly ask you to consider the POV of dozens (maybe hundreds?) of different developers and users from this library. If you don't consider this as an issue, at least consider as an enhancement. Give the possibility to the library users to handle the error if they want. This PR doesn't change the codebase to force everyone to handle, it just gives the option to those who want to handle it properly. I just can't understand why this change can't be added. It doesn't make any logical sense to don't allow it. |
@ggirotto I'm sorry for not keeping up to date with all issues, but the errorListener is added back in version 3.3.0. Does that work for you? |
Hey @renefloor thanks for the quick response. Correct me if I'm wrong, but as far as I understood the current The current implementation doesn't address the open issues requests, since the error will be rethrown anyway. The main goal of all requests - as far as I understood - is to avoid crash tools pollution with undesired connection issues that may happen when downloading images (timeouts, socket, handshake, etc...) since these kind of errors are completely useless to track because there's nothing the developer can do if the user connection is poor/offline, and the current implementation doesn't allow this behavior of intercepting these connection errors and discard them before they're sent to crash/analytics services and tools. |
The PR #891 actually solves your issue in the correct way, because indeed, the |
It's still unclear to me how #891 fixes the issue that this PR solves. We still have no way of using the widget without needing to handle with unnecessary network errors being thrown. #891 adds an way of listening to errors when using From PR description:
If you disagree of this implementation/behavior please let us know because if so I'll create a mirrored fork with this change. |
@ggirotto the rethrow is needed for the error widget to be properly shown. You can see that that is also done by the official Flutter image providers, such as NetworkImage The main issue is/was that the ImageStreamCompleter reports this using if (!handled) {
FlutterError.reportError(_currentError!);
} By linking the errorListener to the ImageStreamCompleter the rethrow is no longer registered using FlutterError.reportError and should not get into any error reporting tools. The rethrow cannot be removed, because that breaks the Image widget, but it also doesn't need to be removed. |
@renefloor Thanks for the update. Just to better understand, now if we specify a CachedNetworkImage(
errorListener: (error) {
// Do something with the error
},
imageUrl: '<URL>',
) ? |
Allow user to send a custom function to track loading image errors.
If the function is sent we also prevent rethrow from being called.
We were receiving millions of errors monthly on simple "socket exception".
It is a non breaking change because if not sent the plugin will behave exactly the same.
To use just add to CachedNetworkImage a function like this: