question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

event.addMetadata incorrectly adds the same key multiple times

See original GitHub issue

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

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

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

Example Repo

  • Create a minimal repository that can reproduce the issue after running yarn install and react-native run-ios/react-native run-android
  • 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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
johnkiely1commented, Oct 1, 2020

Hi @cristianoccazinsp,

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

1reaction
steve-nester-ukcommented, Sep 8, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing error reports - JavaScript - Bugsnag docs
Data can be added key-by-key with a value that is a primitive type, map or array: event.addMetadata('company', 'name', ...
Read more >
Working with object metadata - Amazon Simple Storage Service
Name Description Can user modify the value? Date Current date and time. No Content‑Disposition Object presentational information. Yes Content‑Length Object size in bytes. No
Read more >
Stripe CLI: How to trigger events with nested metadata
if anyone coming here looking for a way to add multiple items in the metadata, you can do so by: Stripe trigger payment_intent.succeeded ......
Read more >
Is it possible to add metadata from different user? — oracle-tech
I logged into database as as USER2 and i have create a Spatial table in schema USER1. After that I tried to insert...
Read more >
Event immutability and dealing with change - Event Store
While there are many types of immutable databases (event stores, streaming databases, and time-series databases, to name a few), an event ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found