sentry-dart
sentry-dart copied to clipboard
How to configure Sentry not to suppress the errors it sees
Hi,
I am starting with Flutter Sentry for Web and it is working but when an error occurs it suppresses the error from being shown on the console. Is there a way to log the error but all it to throw an exception as it would normally do?
Warm regards, Zambet
Thanks for raising the issue.
This is already fixed in https://github.com/getsentry/sentry-dart/pull/533
I think it's already in the latest beta but it will be available in the next version.
Great thanks for your reply, I see that ticket says to always fire the error - is there a way to make it optional as I think that's a useful feature for Flutter Web to have it configurable to be able to hide it from the dev console.
Hi @ueman, I am using Beta 3 which appears to have the change in it but I can still see it suppress the console errors in Flutter Web. Can you confirm?
Error are shown in the debug console (e.g. VS Code or IntelliJ). As far as I know they aren't shown in the browser which is the connected device. You probably should create an issue on the Flutter repo if you want that behavior.
Somethings a picture just helps :-)
Without Sentry I get this when I run the test application from Sentry_Flutter:

When using 6.0.0-beta.3 I do not get anything in the Console of the browser (so there's no way to know an error occurred without watching for the envelope API requests or checking sentry.io).

The request is to have both :-)
Ah I see, yeah that looks like an bug. We'll check it out.
+1 on this. Any updates on when this will be fixed?
Ah I see, yeah that looks like an bug. We'll check it out.
@ueman have you checked this out? I don't remember the outcome of this issue.
This doesn't seem to be fixed, since the overridden onError doesn't call presentError, as seen in:
https://github.com/getsentry/sentry-dart/blob/a60913453866bc81901784aec6fa8aad023135f8/flutter/lib/src/integrations/flutter_error_integration.dart#L22-L98
The default implementation for onError does it, though: static FlutterExceptionHandler? onError = presentError;
See
- https://api.flutter.dev/flutter/foundation/FlutterError/presentError.html
- https://api.flutter.dev/flutter/foundation/FlutterError/onError.html
I think there were problems with the debugPrint breadcrumbs because presentError would call debugPrint. I think those were resolved, but it should be checked again.
@ueman fair point but we always forward the call to the default handler https://github.com/getsentry/sentry-dart/blob/d235a79dc30772bb861de3eec8222cf2300bbd23/flutter/lib/src/integrations/flutter_error_integration.dart#L90-L92
So the problem here is not the FlutterErrorIntegration but rather the RunZonedGuardedIntegration which is responsible for capturing the errors shown in the issue description.
We do log the error tho, https://github.com/getsentry/sentry-dart/blob/d235a79dc30772bb861de3eec8222cf2300bbd23/dart/lib/src/default_integrations.dart#L36-L42
But options.debug should be enabled.
@ueman if there's no runZonedGuarded at all, Flutter only prints out to the console I believe? Maybe in this case, we should do something similar to presentError, which is calling debugPrint or debugPrintStack, so at least is shown?
That's a good question and I'm not really sure. I would believe, that without the runZoneGuarded the default behavior is used, because Sentry doesn't mess with it. Or does Sentry do something that intercepts it somehow?
Nope, we don't do anything, but I believe Flutter itself does something in case there's no runZoneGuarded at all, which is likely printing out to the console, we always forward to the default handler, but in case of runZoneGuarded, and Isolate.current.addErrorListener, no default callbacks exist, so we don't do anything besides logging out to our debug logger.
For FlutterError.onError and PlatformDispatcher.onError, we do call the default handler.
Using debugPrint or debugPrintStack does not yield the same result in the (web) console as and error without sentry. Do we know which method/function to call to have the same formatting (red). like without sentry?
When calling handleUncaughtError it is rendered correctly. This is the same as the default in the platform dispatcher that @ueman linked to when we were discussing the handled flag.
https://github.com/flutter/engine/blob/74a9c7e0f9b16cf8e26b2d1ce7b7777ae2a07572/lib/ui/platform_dispatcher.dart#L1141-L1183