bugsnag-js icon indicating copy to clipboard operation
bugsnag-js copied to clipboard

React Native Android - Duplicated breadcrumbs since 7.11.0 ?

Open cristianoccazinsp opened this issue 4 years ago • 3 comments

Describe the bug

Since upgrading to 7.11.0, I'm observing duplicated breadcrumbs from custom-added log entries (with console.* statements replaced with bugsnag.notify, see below)

Steps to reproduce

Log various events in quick succession, the breadcrumbs prior to the reported log will end up duplicated.

Environment

  • Bugsnag version: 7.11.0
  • React-Native: 0.62.4
  • Device (e.g. iphonex): Android

Example code snippet

I'm intercepting console calls like this in prod/release modes:

console.warn = (arg1, ...rest) => {
  if (excludeMessage.test(arg1)) {
    return;
  }

  conf.bugsnag.notify(new Error(arg1), (event) => {
    event.severity = 'warning';
    event.groupingHash = 'handled.console.warn';

    if (event.errors && event.errors.length) {
      event.errors[0].errorClass = 'JSWarning';
    }

    event.addMetadata('args', {
      arg1: JSON.stringify(arg1),
      info: JSON.stringify(rest),
    });

    return true;
  });
};

Here's an example of a log entry showing the same log statement twice (one with the unhandled variable, which is odd?)

Screen Shot 2021-08-01 at 15 59 05

Did anything change internally and bugsnag is also intercepting console log calls? This does NOT happen on iOS by the way.

Error messages:

cristianoccazinsp avatar Aug 01 '21 19:08 cristianoccazinsp

Hi @cristianoccazinsp

Thanks for reporting. It does look like a bug has been introduced in v7.11.0 resulting in the duplicated breadcrumbs. The bug doesn't look related to how you're intercepting console log calls, it seems to affect breadcrumbs logged for handled errors in general.

We're just investigating the cause and will aim to release a fix in due course.

mattdyoung avatar Aug 02 '21 14:08 mattdyoung

If it helps, I managed to work around it by disabling the "console" logs on the android native side configuration with the following settings (also applied this to the iOS side just to be sure).

config.setEnabledBreadcrumbTypes(new HashSet<BreadcrumbType>() {{
  add(BreadcrumbType.NAVIGATION);
  add(BreadcrumbType.REQUEST);
  add(BreadcrumbType.ERROR);
  add(BreadcrumbType.STATE);
  add(BreadcrumbType.USER);
  add(BreadcrumbType.MANUAL);
  add(BreadcrumbType.PROCESS);
}});

Are there any drawbacks in using this configuration vs using the default one? I also noticed some flags like MANUAL and PROCESS are not documented in the docs (I had to find them in the actual source code / class info), which is a bit misleading.

cristianoccazinsp avatar Aug 02 '21 14:08 cristianoccazinsp

Hi @cristianoccazinsp,

There should be no issues with using this approach. Thanks for highlighting the missing breadcrumb type options, we will look to get the docs updated accordingly.

johnkiely1 avatar Aug 06 '21 10:08 johnkiely1