Skip to content

Crash Reporting for React Native apps #5378

Closed

Description

@ranyefet

Hello,

My name is Ran Yefet, Developer @ http://yes.no
For last 4 months I've been working on our iOS app using React Native (so far it's been great)

We plan to launch soon and we're looking for crash reporting tool.

My first try was Crashlytics, but it only caught Objective-C crashes without any JavaScript crashes.
Also opened a question on stack overflow still waiting for answer.

Next, I tried HockeyApp, I've integrated their SDK and I do see crashes from JavaScript, but the data related to the crash is only useful for Objective-C but not JavaScript so no stack trace, no JS error that was thrown basically not very helpful/useful.
Their response is that either React Native team will provide hooks to get that data or to build something custom.

I found Sentry but their React Native plugin is experimental and not ready for production.

At the current state, I can't find a tool that will solve my problem.

Dear React Native community,

  1. How do you monitor your apps on production?
  2. What tools do you use to catch crashes?
  3. Can anybody help with Integrating one of these tools with React Native? or Provide guidance on how to solve it?

Thanks,
Ran.

Activity

  1. facebook-github-bot commented on Jan 18, 2016

    @facebook-github-bot
    Contributor

    Hey ranyefet, thanks for reporting this issue!

    React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

    • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
    • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
    • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!
  2. corbt commented on Jan 18, 2016

    @corbt
    Contributor

    I agree that this is a great question, and one that I'm wondering about as well. However, Github issues work best when they're saved for actionable problems, not general questions. I think the best place to have this discussion for the moment is probably on Stack Overflow, where you've also posted.

  3. ranyefet commented on Jan 18, 2016

    @ranyefet
    Author

    I agree that It should be on Stack Overflow but I wanted to see if React Native team / community is planing to expose some API or have better tools to easily support this use case.

  4. ranyefet commented on Jan 18, 2016

    @ranyefet
    Author

    Related issue #1194

  5. MuruganDurai commented on Feb 18, 2016

    @MuruganDurai
    Contributor

    @ranyefet hey can you please share some samples or examples to configure sentry for android? Thanks a ton for your help.

  6. ranyefet commented on Feb 18, 2016

    @ranyefet
    Author

    @MuruganDurai well I actually only did that for iOS app. but I think it should be similar.
    I follow the instructions here:
    https://docs.getsentry.com/hosted/clients/javascript/integrations/react-native/

  7. MuruganDurai commented on Feb 18, 2016

    @MuruganDurai
    Contributor

    @ranyefet thanks for quick reply, Yeah I too followed the same but dont know which Raven.js to be used for this code
    Raven
    .config('https://456456456456456dfgdfgee56dfgdf@app.getsentry.com/er5434', { release: RELEASE_ID })
    .install();

  8. ranyefet commented on Feb 18, 2016

    @ranyefet
    Author

    In my app I created a file in app/utils/raven.js
    and I require it at the start of index.ios.js:

    if(!__DEV__) {
        var Raven = require('./app/utils/raven');
    }
    

    raven.js file looks like:

    // Sentry Integration
    var Raven = require('raven-js');
    require('raven-js/plugins/react-native')(Raven);
    
    Raven
      .config('https://456456456456456dfgdfgee56dfgdf@app.getsentry.com/er5434', { release: RELEASE_ID })
      .install();
    
    export default Raven;
    
  9. MuruganDurai commented on Feb 18, 2016

    @MuruganDurai
    Contributor

    @ranyefet Thanks a ton. Will try & let you know and in the mean time I configured crashlytics too..

  10. crockpotveggies commented on Mar 9, 2016

    @crockpotveggies

    Any luck on using Raven here? I'm not getting global crash reports at all :/ Raven is reporting errors that I explicitly attempt to catch, but anything that causes the app to crash & close is not reported. Do I need to add a global handler via ErrorUtils?

  11. faceyspacey commented on Apr 29, 2016

    @faceyspacey

    does getSentry capture native crashes or do you basically have to setup both getSentry and something like Crashlytics? My app has no custom native modules of its own, but when developing I do receive native crashes with a completely objective C stack trace. In addition to the getSentry source-map-aware javascript crash reports, I would like to have reports for these types of crashes as well and the type where the app instantly shuts down. Does Crashlytics even capture that sort of stuff?

    Anyone have an ideal setup going for React Native crash reporting?

  12. mikelambert commented on Apr 30, 2016

    @mikelambert
    Contributor

    Crashlytics by default only does "real" errors (ie Swift/ObjC/Java), and doesn't catch any JS errors. So if you want the "type where the app instantly shuts down", Crashlytics should be good for you.

    I have managed to set up JS crash reporting in my app, to push to both Crashlytics as well as TrackJS. (Haven't tried Sentry or Raven.) I haven't published it all up nice and proper yet, but both work for me now (for my yet-to-be-published react rewrite of my app).

    If you're curious to do what I'm doing for Crashlytics:

    1. https://github.com/corymsmith/react-native-fabric (which has my recent pull request that may not have been published to NPM yet)
    2. https://github.com/mikelambert/react-native-fabric-crashlytics - what traps errors and sends them in to crashlytics
      (They will then show up as Non-Fatal Exceptions within the Crashlytics UI)

    Or if you prefer TrackJS:
    https://github.com/mikelambert/react-native-trackjs - what wraps the trackjs library, with some semi-major hacks (creating a dummy 'document', in particular, being the one most likely to cause issues), to publish to their server. though the trackjs team is now looking to make it possible to do this with less hackery.

    I haven't published react-native-fabric-crashlytics or react-native-trackjs to NPM yet (my laptop died and is in the apple repair all week), so would have to point at my github for now, or just wait a week or so.

  13. samonderous commented on Sep 8, 2016

    @samonderous

    @mikelambert I'm testing react-native-fabric-crashlytics but am unable to get the JS stacktrace to appear on crashlytics. I'm doing something like this:

    crashlytics.init();
    Crashlytics.crash()

    Basically generating a crash right after I init your lib. I made sure I bypassed your DEV check to test on dev. Anything else I'd have to do on dev to test this? Thanks!

  14. mikelambert commented on Sep 9, 2016

    @mikelambert
    Contributor

    Are you generating a JS crash or a native crashlytics crash, with that
    line? This library only catches stack traces for JS exceptions, not native
    crashes (which get handled by the crashlytics runtime directly).

    Other ideas:

    • the Dev check (which you mention)
    • did you initialize Crashlytics inside the native app code for your app?
      (Follow the crashlytics/fabric setup code for this)
    • what platform are you seeing this on, android or iOS? Have you tried the
      "other platform"?
    • do you see a native crash (but not a js crash)? Or do you not see any
      crash at all?
      On Thu, Sep 8, 2016 at 6:39 PM Saureen Shah notifications@github.com
      wrote:

    @mikelambert https://github.com/mikelambert I'm testing
    react-native-fabric-crashlytics but am unable to get the JS stacktrace to
    appear on crashlytics. I'm doing something like this:

    crashlytics.init();
    Crashlytics.crash()

    Basically generating a crash right after I init your lib. I made sure I
    bypassed your DEV check to test on dev. Anything else I'd have to do on dev
    to test this? Thanks!

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub
    #5378 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/AHlba4-WnJkBBAbiv3u5wOwYc2C8hy-Oks5qoJy_gaJpZM4HG9tj
    .

  15. samonderous commented on Sep 9, 2016

    @samonderous

    @mikelambert I'm testing in react-native, calling Crashlytics.crash() right after I do a crashlytics.init() in a render() call of a component.

    Bypassing DEV check just fine. Initializing Crashlytics with this as per docs at very end of didFinishLaunchingWithOptions.

    [Fabric with:@[[Crashlytics class]]];

    I have both react-native-fabric & react-native-fabric-crashlytics installed. I was only using Crashlytics.crash() to test crashing the app in the render() call of a component (purely for test). Are you saying this actually causes a native crash and would not get reported with render() at the top o of a JS callstack? Have not tried Android but will try next.

    I switched out Crashlytics.crash() with just throwing a JS exception and now see a non-fatal reported in the Crashlytics dashboard. What I don't see is the render() call at the top of the stack.

    Non-fatal Exception: null is not an object (evaluating 'internalInstance.getHostNode')
    0 ??? 0x0 getHostNode (index.ios.bundle?platform=ios&dev=true&minify=false:258133)
    1 ??? 0x0 getHostNode (index.ios.bundle?platform=ios&dev=true&minify=false:285957)
    2 ??? 0x0 getHostNode (index.ios.bundle?platform=ios&dev=true&minify=false:258133)
    3 ??? 0x0 updateChildren (index.ios.bundle?platform=ios&dev=true&minify=false:277141)
    4 ??? 0x0 _reconcilerUpdateChildren (index.ios.bundle?platform=ios&dev=true&minify=false:270181)

  16. mikelambert commented on Sep 9, 2016

    @mikelambert
    Contributor

    So yeah, that was my point about Crashlytics.crash() and native vs JS exceptions. Glad to hear you're seeing the non-fatal in the dashboard now (though not sure why you didn't see a fatal when calling Crashlytics.crash()...)

    As far as the strange non-render() stacktrace, I'm not sure I know what's going on with that. Searching for null is not an object (evaluating 'internalInstance.getHostNode') online also doesn't reveal too many others encountering that particular error.

    I'd suggest including your JS-exception-throw outside of the render() flow to see if you can get a better stack trace. Also I'd suggest using throw new Error("...") instead of throw "..." if that applies, since it's important for getting proper stacktraces with react native. Not sure what you're doing exactly there in your testing.

    Sorry I don't have any more great suggestions for you.

  17. joshwold commented on Nov 2, 2016

    @joshwold

    Just a heads up that Bugsnag released their React Native library which gets crash / error data from both the JS and the native layer.

    https://docs.bugsnag.com/platforms/react-native/

  18. ehfeng commented on Jun 16, 2017

    @ehfeng

    Sentry's React Native support is now officially released with support iOS and Android. This includes both JS source map decompression as well as Swift/Obj-C symbolification

  19. locked as resolved and limited conversation to collaborators on May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions