-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Don't call out to the default handler in production mode #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think I've just argued myself into hiding the PR behind a flag, at the very least - but I'm going to let it sit until the right approach is settled on |
The 3rd approach involves using a different plugin, e.g. getsentry/raven-objc. I think it's nice to be able to use Raven.js if possible, especially for cases where you're using the same React code on the web / on mobile devices. So I'm going to propose exploring #2. |
The thing that worries me about option 2 is that it's a bit deceiving for people who feel strongly about crashing hard. The usual rationale for doing that (AFAIK) is to avoid letting the app get into a broken state, and especially to avoid it persisting any of that broken state. Waiting for the exception to send (or persist - offline support) gives the application plenty of time to do something bad |
Total shot in the dark – I wonder if it's possible to do some kind of synchronous processing inside Raven.js while the HTTP request is being transmitted (e.g. synchronous XHR), so that control flow doesn't return to React Native. But I'm guessing that React Native doesn't actually support synchronous XHR. |
I do think it's important for both minimizing possible damage and providing the best possible user experience to let the JS crash and RN restart as soon as possible after a crash happens. Option 3 seems like a solid way to accomplish that, and also presumably would make it easier to integrate sentry into an app as well (because you only have to add code in one place, on the native side). Another alternative would be to push the error to |
I'm in favor of this. |
AsyncStorage doesn't block - and in typical use on iOS it adds 200ms On Mon, Mar 28, 2016, 16:55 Ben Vinegar [email protected] wrote:
|
In favor of that over hitting the network, though! On Tue, Mar 29, 2016, 09:45 Ian MacLeod [email protected] wrote:
|
What are the odds that writing to AsyncStorage has the same problems as firing an HTTP request? i.e. that the process terminates before the write occurs |
So far in production the number of exceptions reported that way equals the number of exceptions reported by Sentry native. I might be just lucky though, not relying on that too much since I also have native handlers as a fallback.
I don't think it's complicated - it just requires quite a few additions to your native code, but AFAIK that's the most stable way to do it. If we decide to bundle native code for React Native, we could do a blocking write on native side and crash after that happens which should not produce any issues later (you can e.g. write to NSUserDefaults and read that from Javascript with
Besides that, what I like in JS approach is you can send source maps and get nice stack traces for free. I am giving my +1 to this #533 (comment) - I think it should cover most cases, the code is pretty portable and write/read is like 15 lines of code. |
One thing I don't understand in this PR (please enlighten me) is -> if you overwrite error handler and do not call it in production - app is never going to quit because of React Native JS exception. If that's something major, how you are supposed to reload the app then? (actually I just came up with an idea to reload the app just like refreshing browser w/o quitting!) |
Would need some research on whether FB waits for any pending writes before crashing in earnest (I doubt it, though) |
In case it's helpful to others, here's an attempt at approach 2 described above. Despite the risk of waiting <1 sec before crashing, it made more sense for my use case; a user may not immediately re-open the app (or may just decide to uninstall!) in the event of a crash. https://gist.github.com/abc123s/2d4bef879f79ff77b54703085bb077b0 |
Alright, I'm looking at tackling option 2 +
This should hopefully make #279 a lot more straightforward, too @benvinegar I'm noticing that the current payload does not seem to include a |
Alternatively, this could be implemented as a transport (that passes through to the original one?). I would need to think a bit more about how that would be structured, though |
Yeah, it will just use the creation time when received on the server end. But in this case it makes sense to just start collecting it (and more accurate). I think we may also have issues where breadcrumb timestamps don't match this event creation time because of clock skew issues. |
👍 |
Okay, so just had a discussion with @mattrobenolt about this. We made this change because clients often have clocks that are just ... wildly inaccurate. Since we don't have control over that, the creation time is used. I think in the case of React Native, where there's more control over the client (?), and because you're restoring from a previous event, it makes sense to send a timestamp. But I'm not sure if we should change the default behavior without more thought. |
Sounds good - I'll bake it in from the plugin side only |
Does the general approach of |
So, I'm always super hesitant to add more API methods, and I'd like to avoid it as much as possible. Given that, I think you could get away with just adding a single Basically, you use It's a little hacky, but it lets us prove this out a little more without committing to a bigger API. Thoughts? |
Yeah, sounds good to me; less surface area for me to potentially screw up. Thanks for the feedback! Saved me a bunch of potentially wasted time/effort :) |
Closing in favor of #626 |
A continuation of the discussion in #515 and one way to fix #468 - however, this is a controversial change!
There are a few options as I see it (when in react native's production mode):
IMO the 3rd approach is ideal, but I have no idea how much work it would be