Skip to content

[react-native] capture and report fatals on next launch - #626

Merged
benvinegar merged 1 commit into
masterfrom
unknown repository
Aug 2, 2016
Merged

benvinegar merged 1 commit into
masterfrom
unknown repository

Conversation

@nevir

@nevir nevir commented Jun 24, 2016 •

Copy link
Copy Markdown
Contributor

Addresses #468, #533, and maybe #489


When a fatal (global) error is thrown, raven-js now captures it and persists it before calling the original error handler when in production mode (e.g. so the JS error can bubble out and crash the app). Then, when the react native plugin initializes, it checks for a persisted error, and reports it.

Some finer details:

  • In development mode, errors are not persisted, and the default error handler is always called. This allows redboxes to pop as expected.
  • Any subsequent fatals thrown while raven-js is persisting the first one are ignored (we want to crash ASAP).
  • If the error fails to report; it won't be cleared. This provides a very rudimentary retry mechanism (true offline support should be implemented more robustly, IMO).
  • I snuck in Raven.addShouldSendCallback so that the react-native plugin doesn't bash over existing configurations
  • onInitialize is useful for detecting if an error was previously reported (say, if you want to pop a "we're sorry" alert, or fix up your store)

This change is Reviewable

@Sija

Sija commented Jun 24, 2016

Copy link
Copy Markdown
Contributor

This would be handy as a transport in other environments too (think no internet situations)

Comment thread src/raven.js Outdated
* @return {Raven}
*/
addShouldSendCallback: function(callback) {
var prevCallback = this._globalOptions.shouldSendCallback;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh, again hesitant to add more API methods – even though I know this solves some serious problems.

We've talked about just merging shouldSendCallback / dataCallback in a major version change (4.0).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm writing a small plugin to solve #279. This API method would be useful.

@SergeyKorochansky

Copy link
Copy Markdown

I also bumped into this issue. Thank you for PR!

@SergeyKorochansky

Copy link
Copy Markdown

@nevir Thanks for PR. I merged your PR in our fork and it works great!

@benvinegar

Copy link
Copy Markdown
Contributor

@nevir – possible to update this to reflect changes in #636?

@Kerumen

Kerumen commented Jul 26, 2016

Copy link
Copy Markdown

Ping @nevir, it would be awesome if you could update the PR. Thanks!

@nevir

nevir commented Jul 26, 2016

Copy link
Copy Markdown
Contributor Author

Ack, sorry! Will get to this in the new few days

@nevir

nevir commented Jul 31, 2016

Copy link
Copy Markdown
Contributor Author

Alright, rebased it off of the latest! PTAL

@Kerumen

Kerumen commented Aug 2, 2016

Copy link
Copy Markdown

Ping @benvinegar

@benvinegar
benvinegar merged commit d9c9d85 into getsentry:master Aug 2, 2016
@benvinegar

Copy link
Copy Markdown
Contributor

Here goes nothing!

@nevir

nevir commented Aug 2, 2016

Copy link
Copy Markdown
Contributor Author

Sweet!

@abc123s

abc123s commented Aug 12, 2016 •

Copy link
Copy Markdown

@nevir
I have a question on the changes in the this commit.

  1. In lines 87-104 of plugins/react-native.js, isn't it possible for originalCallback to be undefined, causing the plugin to crash for non-fatal errors?

@blackxored

Copy link
Copy Markdown

@abc123s Indeed, I'm actually having that exact error atm.

@TSMMark

TSMMark commented Dec 16, 2016

Copy link
Copy Markdown

For the record, #692 addresses @abc123s's issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants