Skip to content

React Native iOS does not report error causes (or multiple errors from an error array) #1956

@getsaf

Description

@getsaf

Describe the bug

package: @bugsnag/react-native
iOS does not report error causes (It works fine in Android).

Root cause is that the iOS event deserializer is hard-coded to only inspect/deserialize the first error that is reported

Additionally, I found that the bugsnag-cocoa pod also hard-codes attachment of stack traces to the first error in the BugsnagEvent#errors array in the attachCustomStacktrace function which is also called in the event deserializer here (this makes it difficult to provide a full solution without also making changes to bugsnag-cocoa or duplicating some logic from bugsnag-cocoa into the bugsnag-js repo).

- (void)attachCustomStacktrace:(NSArray *)frames withType:(NSString *)type {
    BugsnagError *error = self.errors.firstObject;
    error.stacktrace = [BugsnagStacktrace stacktraceFromJson:frames].trace;
    error.typeString = type;
}

Steps to reproduce

  1. Report an error with a cause property assigned
  2. View the report in the Bugsnag web UI
  3. See the cause is not reported

Environment

  • Bugsnag version: 7.20.2
  • Browser framework version (if any):
    • n/a
  • Server framework version (if any):
    • n/a
  • Device (e.g. iphonex):
    • Any iPhone device

Example code snippet

  const cause = new Error('This is the cause');
  const error = new Error('This is the error', {cause});
  bugsnag.notify(error);

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogWe hope to fix this feature/bug in the futurebugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions