sentry-dart icon indicating copy to clipboard operation
sentry-dart copied to clipboard

How to configure Sentry not to suppress the errors it sees

Open zambetpentru opened this issue 4 years ago • 7 comments

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

zambetpentru avatar Aug 09 '21 16:08 zambetpentru

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.

ueman avatar Aug 09 '21 16:08 ueman

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.

zambetpentru avatar Aug 09 '21 17:08 zambetpentru

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?

zambetpentru avatar Aug 10 '21 20:08 zambetpentru

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.

ueman avatar Aug 11 '21 13:08 ueman

Somethings a picture just helps :-)

Without Sentry I get this when I run the test application from Sentry_Flutter:

image

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).

image

The request is to have both :-)

zambetpentru avatar Aug 11 '21 16:08 zambetpentru

Ah I see, yeah that looks like an bug. We'll check it out.

ueman avatar Aug 11 '21 17:08 ueman

+1 on this. Any updates on when this will be fixed?

hitokiri82 avatar Dec 10 '21 11:12 hitokiri82

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.

marandaneto avatar Nov 17 '22 09:11 marandaneto

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 avatar Nov 17 '22 10:11 ueman

@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

marandaneto avatar Dec 09 '22 13:12 marandaneto

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?

marandaneto avatar Dec 12 '22 07:12 marandaneto

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?

ueman avatar Dec 12 '22 07:12 ueman

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.

marandaneto avatar Dec 12 '22 07:12 marandaneto

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?

Bildschirm­foto 2023-01-17 um 13 32 39

denrase avatar Jan 17 '23 13:01 denrase

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

denrase avatar Jan 17 '23 13:01 denrase