-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add a pathStrip
option to the react native plugin
#515
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
Cool. My only comment is: can we come up with a better name than Some quick ideas:
|
Should/can I change default behavior to not rethrow as part of this as well? |
Maybe. Another possibility (to fix #468) is we verify the request is sent before calling the original error handler. I'm not sure if that's a good idea or not though – e.g. if the crash takes ~500ms to actually appear / manifest in the app. |
Alright, I'll stick with just the option for now, that can be layered on later |
Well, I like |
Well, I can do the |
Here's the easy way out of |
Aha, ok. So, after further testing, iOS react's dev mode does use the global exception handler to display error redboxes. It seems like the better behavior here is for default behavior to rethrow in dev mode (for redbox), and not to rethrow otherwise (to prevent the exception from bubbling out). That preserves the behavior of raven-js 1.x, at least Pushed an update with that behavior |
@nevir – Hey, just a heads up I was out for vacation but I'm back to look at this now. I just want to fire up this patch and verify the behavior personally before accepting. Probably by EOD tomorrow. |
@@ -73,9 +87,12 @@ function reactNativePlugin(Raven) { | |||
|
|||
var defaultHandler = ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler() || ErrorUtils._globalHandler; | |||
|
|||
var rethrow = pluginOptions.rethrow || __DEV__; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If rethrow
is false, this will still throw in __DEV__
.
How about:
var rethrow = 'rethrow' in pluginOptions ? pluginOptions.rethrow || __DEV__;
@nevir – btw, now that we've figured out what the default behavior should be (with |
Probably not! updating to cut that out |
This allows for the user to customize how raven normalizes file URIs. For example, to support a Code Push bundle in addition to the baked in one: ```js Raven.addPlugin(require('raven-js/plugins/react-native'), { // Strip all paths up to the last /, resulting in paths like // `/main.jsbundle`, `/app.jsbundle`, etc. pathStrip: /^.*(?=\/)/, }); ```
Updated - PTAL |
pathStrip
option to the react native plugin
I'm unsure how to appropriately test the |
@nevir – first off, thanks for sticking with this. Will definitely merge in. One last question re: |
Uncaught JS exceptions do crash the app by default (i.e. including Raven prevents that) want me to bring the option back? :P |
The problem is that if the app is allowed to crash, the exception will be never caught. Or Raven could defer the default handler until the exception is reported, but you risk additional state corruption; there's no way to pause the rest of the VM |
(A better solution might be to have react-native support in the ObjC and Java clients; but that sounds thorny) |
If you don't mind, let's pull out your (If this is a pain in the ass I can do it for you.) |
I understand the predicament where the app crashes before the HTTP request can go out ... but I'm not sure we should just swallow the exception entirely. Maybe waiting for the HTTP response (w/ a short timeout) is best (e.g. rethrow in .5 secs). |
Sounds good, updated to just that commit |
Add a `pathStrip` option to the react native plugin
👍 |
Added #533 to kickstart the conversation |
This allows for the user to customize how raven normalizes file URIs. For example, to support a Code Push bundle in addition to the baked in one: