event.addMetadata incorrectly adds the same key multiple times
See original GitHub issueDescription
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:
However, when the log is received, some keys are nested and duplicated into other keys, like this:
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 theapplication:didFinishLaunchingWithOptions:
method in yourAppDelegate
class? -
(Android only)
BugsnagReactNative.start(this)
is present in theonCreate
method of yourMainApplication
class?
Example Repo
- Create a minimal repository that can reproduce the issue after running
yarn install
andreact-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:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Hi @cristianoccazinsp,
This has now been fixed and is released in v7.4.0.
We have been able to replicate this issue. We are going to take a look.