-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
Doesn't Catch Native Exceptions before the Javascript Runs #542
Comments
Yeah, this is correct. |
I was thinking that the DSN could be a native variable rather than a JS string, and that var could be passed back to the JS side if necessary as a const (React Native supports constants over the bridge). IMO if your app is crashing from native exceptions before the JS runs, but not reporting them to Sentry, thats a big deal! Is there any problem with the approach above? ie - instantiating the native client twice? Kinda feels like something this lib should do by default. |
That could be an approach we could take, problem with this is where to set the DSN natively?! I'll also be honest with you, this will probably not be changed in the near future. but it's not been decided yet. If we do, we'll think about how to handle this properly. But in general I agree with what you are saying (how it should/could work). |
Understood, thank you. One last Q - Is there any problem with the approach above? ie - instantiating the native client twice? Just wanna be sure that’s not going to cause some type of collision, etc. |
Hi @HazAT // file: @sentry/react-native/android/build.gradle
dependencies {
implementation 'com.facebook.react:react-native:+'
- implementation 'io.sentry:sentry-android:1.7.23'
+ api 'io.sentry:sentry-android:1.7.23'
} Then in our Android MainApplication.java we can do: Sentry.init(sentryConfig.dsn, AndroidSentryClientFactory(applicationContext)) We are using |
Any update on this? |
I am using
And faced with this problem. Sometimes an app crashes within java or binary code before js initialization. I moved initialization to native level by adding the following: AndroidManifest.xml
in app/build.gradle
it is catching java errors even from I still keep
which is probably initializing sdk second time. But looks like it's working fine. Will post updates. |
@punksta Any updates on this? Did you stumble upon any issues when using this approach of initializing the SDK twice? |
@thesagarshakya I haven't noticed any major issues. The only issue I noticed is crashes from binary(c++) code are not linked to a release in the dashboard, but I guess it's a different issue. |
@HazAT Any updates on this? Another 1 year have gone by.. |
We've been discussing possible solutions internally, this is a pretty complex and difficult issue and if we find a good solution we'll make it happen. But for now as a workaround you can initialize the SDKs twice, by this I mean calling |
We're planning to tackle this soon. Sorry for the delay |
With this PR #1259 merged, it's possible now to catch native errors before the JS code runs. You would have to manually initialize the SDK on the native layer yourself, and pass |
@jennmueng do you know how the RN engine gets started on Android? is it thru ContentProvider? wondering if getsentry/sentry-dart#265 (comment) is also an issue for RN |
I'm not fully sure myself as I've not really worked with it, but I think it should started from the Application class. |
yeah just looked up inside of an old demo, RN creates an so yeah a few things could be caught by the SDK, but RN also has ContentProvider, See this https://github.com/facebook/react-native/blob/6e6443afd04a847ef23fb6254a84e48c70b45896/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobProvider.java so what I've guessed is partly true. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
you can achieve that by manually initing the Native SDKs https://docs.sentry.io/platforms/react-native/manual-setup/native-init/ |
OS:
Platform:
Output of
node -v && npm -v && npm ls --prod --depth=0
Config:
I have following issue:
I'd like to use Sentry to capture information in early Android hooks like
MainActivity#onCreate
. Unfortunately, because this lib requires the JS to initialize the Native client over the bridge, those early hooks will no-op because it hasn't initialized yet.Steps to reproduce:
Sentry.capture("Hello!")
toMainActivity#onCreate
Actual result:
Expected result:
FWIW, my current work around is to init the client early in the
MainApplication#onCreate
. Then my JS runs, and re-inits the Sentry client through the Native Module API. Seems OK, but not ideal!Thanks for all the hard work!
The text was updated successfully, but these errors were encountered: