bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
370 stars 121 forks source link

iOS Library misbehaves when dropping breadcrumbs #467

Closed chetstone closed 4 years ago

chetstone commented 4 years ago

Description

I am using configuration.consoleBreadcrumbsEnabled = true; to leave breadcrumbs, and some of my console statements are too long. As expected, bugsnag drops the longish breadcrumbs and displays a warning on the console.

Issue

Bugsnag seems to get overenthusiastic about dropping the breadcrumbs, because for every too-long console message printed, it prints the "Dropping breadcrumb because it's too long" message between 6 and 10 times. Then apparently it doesn't release the memory involved because the app eventually crashes with an out-of-memory error. (The memory problem doesn't happen when I use reasonably sized console messages).

Environment

Library versions:

yarn list v1.22.4
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ bugsnag-react-native@2.23.6
├─ react-native-code-push@5.7.0
└─ react-native@0.61.4

Example Repo

Example code snippet

import { Client, Configuration } from 'bugsnag-react-native';
// Note I am initializing bugsnag from the initializer of an altjs (flux) store so I can dynamically grab my 
// codeBundleID from codepush if a codepush build is installed

      this.on('init', () => {
        info(`CodePush store init`);
        // bugsnag
        const configuration = new Configuration(
          'myAPIkey'
        );
        configuration.consoleBreadcrumbsEnabled = true;
        codePush
          .getUpdateMetadata()
          .then(
            update =>
              update && (configuration.codeBundleId = update.description)
          )
          .finally(() => (this.state.bugsnag = new Client(configuration)));
      });
    }
Error messages: ``` 2020-07-09 15:58:37.181 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": a very long line truncated for clarity.} +2s 2020-07-09 15:58:37.216 MalaDebug[669:798780] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 15:58:41.850 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 15:58:42.513 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 15:58:42.538 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 15:58:45.275 MalaDebug[669:798638] Unlock All Orientations 2020-07-09 15:58:49.943 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 15:58:49.960 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:00:41.515 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:00:41.531 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:00:44.302 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC... } +2m 2020-07-09 16:00:44.314 MalaDebug[669:799008] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:00:46.663 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:00:46.666 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:00:46.682 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:00:46.684 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:29.215 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:29.216 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:29.232 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:29.234 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:40.613 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC...} +56s 2020-07-09 16:01:40.628 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:40.636 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:40.637 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:41.546 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:41.549 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:41.551 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:41.568 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:41.571 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:01:41.572 MalaDebug[669:797383] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:43.793 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC... } +1m 2020-07-09 16:02:43.801 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:43.805 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:43.806 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:43.807 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:45.017 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC... } +1s 2020-07-09 16:02:45.035 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:45.037 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:45.038 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:45.039 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:45.040 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:45.977 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC... } +961ms 2020-07-09 16:02:45.988 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:45.995 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:46.006 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:46.007 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:46.008 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:46.011 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:46.974 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC...} +997ms 2020-07-09 16:02:47.009 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.011 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.013 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.014 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.015 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.015 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.016 MalaDebug[669:799220] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.978 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC...} +1s 2020-07-09 16:02:47.997 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:47.998 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:48.001 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:48.002 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:48.003 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:48.004 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:48.005 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:48.005 MalaDebug[669:799252] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.153 [info][tid:com.facebook.react.JavaScript] TimerActions:debug Saving Timer in local accumulations:Timer:8943963e-7b11-4652-8c81-b9cf48ecf71a, data {"ColorStore": ETC...} +1s 2020-07-09 16:02:49.171 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.173 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.174 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.175 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.176 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.176 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.177 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.179 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit 2020-07-09 16:02:49.199 MalaDebug[669:799036] Dropping breadcrumb (Console) exceeding 4096 byte size limit ```

I wasn't sure whether to file this issue here or with bugsnag-cocoapods but figured I'd start here since it is react-native I'm using.

steve-nester-uk commented 4 years ago

@chetstone thanks for raising, I was able to reproduce the issue and we will look into possible fixes.

chetstone commented 4 years ago

Thanks. On possible improvement might be to truncate the breadcrumb rather than drop it.

On Fri, Jul 10, 2020 at 07:15 Steve Nester notifications@github.com wrote:

@chetstone https://github.com/chetstone thanks for raising, I was able to reproduce the issue and we will look into possible fixes.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bugsnag/bugsnag-react-native/issues/467#issuecomment-656671090, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHOLV4GIKUQQQE2QWOCODLR24H7TANCNFSM4OWCEEJQ .

mattdyoung commented 4 years ago

@chetstone The code that causes this issue is removed in bugsnag-cocoa v6 which is soon to be included in a new major release of the React Native Bugsnag library, so that will resolved this once released.

johnkiely1 commented 4 years ago

Hi @chetstone The new version of the React Native Bugsnag library has now been released. Versions from v7.3 onwards make use of v6 bugsnag-cocoa. Here is a link to the current latest version; v7.3.3.