[PLAT-5129 ] Fix reporting of user events with multiple errors #821
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
This change is necessary for the correct reporting of native module promise rejections from react native.
Although the crash reports received by the Cocoa notifier and stored to disk contained the native stack trace, the reports sent to the back-end were missing the native error.
Changeset
-[BugsnagEvent toJson]
was ignoring the errors array ifuser.overrides.customStacktraceFrames
anduser.overrides.customStacktraceType
were set in the payload, which is the case for RN native promise rejections.This was not a problem when events were only expected to have a single error, but RN native promise rejections may have a second error that represents the native stack.
This change ensures the customException only overrides the first error, leaving the native one alone.
Testing
I pushed a version of this code to bugsnag-js in order to see the effect on the e2e tests. This change allowed
Scenario: Handled JS error with native stacktrace
to pass theAnd the payload field "events.0.exceptions" is an array with 2 elements
check and several others, although changes to the scenario will be required to cater for the platform-specific format of Cocoa crash reports - https://buildkite.com/bugsnag/at-bugsnag-react-native/builds/796#36f69338-2aaf-4436-a5f1-563642c3a4f1/458A unit test case was added to this project, which fails without the change to
-[BugsnagEvent toJson]
but passes with it.