Bugsnag-js: event.addMetadata incorrectly adds the same key multiple times

Created on 5 Sep 2020  路  8Comments  路  Source: bugsnag/bugsnag-js

Description


I'm adding extra info to the metadata object (with addMetadata), but for some reason json keys are being nested and added twice. This didn't happen before the migration to @bugsnag/react-native: 7.3.3

Issue


The following code is used in the onError callback to add extra data:

image

However, when the log is received, some keys are nested and duplicated into other keys, like this:

image

This gets even worse the more objects are added to the log, ending up with massive payloads.

Environment

Library versions:

@bugsnag/react-native: 7.3.3
react-native: 0.62.2
  • iOS/Android version(s): All
  • simulator/emulator or physical device?: Device
  • debug mode or production?: Prod

  • [X] (iOS only) [BugsnagReactNative start] is present in the
    application:didFinishLaunchingWithOptions: method in your AppDelegate
    class?

  • [X] (Android only) BugsnagReactNative.start(this) is present in the
    onCreate method of your MainApplication class?

Example Repo

  • [X] Create a minimal repository that can reproduce the issue after running
    yarn install and react-native run-ios/react-native run-android
  • [X] Link to it here:

Example code snippet

bugsnagConf.onError = function(event) {
  if (conf.env === 'dev'){
    console.warn("Bugsnag error not sent: ", event, event.errors);
    return false;
  }
  else{

    if (global.store){
      let state = global.store.getState();
      if(!state.settings.autoSendErrorLogs){
        return false;
      }

      let queueInfo =  {
        queue: {
          total: String(state.queue.total),
          error: String(state.queue.errors)
        },
        sync: {
          status: state.sync.status,
          statusInfo: state.sync.statusInfo,
          lastSync: state.sync.lastSync ? (new Date(state.sync.lastSync).toISOString()) : state.sync.lastSync,
          lastUpdate: String(state.sync.lastUpdate),
          currentTime: new Date().toISOString()
        },
        network: JSON.stringify(state.network)
      };

      event.addMetadata('queueInfo', queueInfo);

      return true;
    }
  }
};

I would love to know if this is an usage issue or an actual bug. Either way, it is increasing data usage significantly.

bug released

All 8 comments

Update: While debugging, there doesn't really seem like there are duplicate keys. Any chance bugsnag on the server side is causing this?

Update 2: Looks like this doesn't happen all the time, but only for android devices.

@cristianoccazinsp
Are you able to readily reproduce this when testing?

If so, would you be able to log out the queueInfo object in full when this happens so we can see exactly what gets sent in the payload?

Could you contact [email protected] referencing this issue and provide both the logged metadata and a link to the exact occurrence which that relates to in your Bugsnag dashboard using the Copy event link option shown:
Screenshot 2020-09-07 at 18 00 43

Hello,

I have done what was requested. Here's the capture showing a breakpoint with the metadata object that's set to the bugsnag's event. Not sure if this is what you were looking for:

log

Note: the app may be different, but the code and bug is exactly the same.

We have been able to replicate this issue. We are going to take a look.

Hello guys,

Any estimate about when this may get resolved? We are looking into pushing a new release shortly and are wondering if we should wait or not for this to be addressed.

Thanks.

@cristianoccazinsp Sorry, I do not have an estimate for the resolution as yet, but we will keep this thread posted with any updates.

This has been transferred to the bugsnag-js repo as the Bugsnag react native library is now part of this repository (as of v7.3).

Hi @cristianoccazinsp,

This has now been fixed and is released in v7.4.0.

Was this page helpful?
0 / 5 - 0 ratings