After upgrade sentry, app has the issue "App Start Span could not be finished. `Sentry.wrap` was called before `Sentry.init`."
OS:
- [ ] Windows
- [ *] MacOS
- [ ] Linux
Platform:
- [* ] iOS
- [ ] Android
SDK:
- [ *]
@sentry/react-native(>= 1.0.0) - [ ]
react-native-sentry(<= 0.43.2)
SDK version: 5.22.3
react-native version: 0.72.4
Are you using Expo?
- [ ] Yes
- [ *] No
Are you using sentry.io or on-premise?
- [ ] sentry.io (SaaS)
- [ ] on-premise
If you are using sentry.io, please post a link to your issue so we can take a look:
[Link to issue]
Configuration:
(@sentry/react-native)
Sentry.init({
dsn: 'https://[email protected]/...'
// other options
});
I have the following issue:
[Description]
After upgrade sentry, app has the issue "App Start Span could not be finished. Sentry.wrap was called before Sentry.init." I use CodePush.getUpdateMetadata()
Steps to reproduce:
- Step 1
- Step 2
Actual result:
[Actual result]
Expected result:
[Expected result]
Hi @erichou668, thank you for the message,
can you share from what version of the Sentry RN SDK have you upgraded?
Could you share a code snippet explaining when and where do you call Sentry.wrap and where and when do you call Sentry.init?
Closing this due to inactivity. If this is still an issue feel free to comment here or open a new issue if the context changed.
I'm experiencing the same behaviour after upgrading from 5.5.0 to 5.25.0. The issue appears on both Android and iOS (I build using RN 0.71.8).
Here is what my App.js looks like
import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: myDSN,
attachScreenshot: true,
beforeSend(event) {
return event;
},
});
function App () {
// ... My code here
<Sentry.ErrorBoundary
fallback={({ error, componentStack, resetError }) => (
// ... My code here
)}
>
<MyComponent/>
</Sentry.ErrorBoundary>
}
const SentryWrappedApp = Sentry.wrap(App);
export default SentryWrappedApp;
I'm also experiencing this issue on a dev build with React Native and Expo. Just installed Sentry for the first time
Same issue. Expo: 50.0.17, React Native: 0.73.6
Facing this issue when testing using Expo Go app also. Expo: 50.0.19, React Native: 0.73.6 Edit: Tested on Expo: 51.0.24, React Native: 0.74.3 also, same issue happening. My initialization is exactly like @mednche except i am using Bugsnag's ErrorBoundary instead of Sentry's.
Experiencing this as well, exact same situation as @mednche
Also experiencing.
Also experiencing.
Also experiencing.
Same with Expo 51 / React Native 0.75!
@krystofwoldrich could you please reopen this issue
My bad I'm not affected anymore, I found out what was wrong in my code 🤦♀
I had:
// In _layout.tsx
myCustomInitSentryFunction()
const RootLayout = () => {
// ...
}
export default Sentry.wrap(RootLayout); // ✅ always called
// In MyIsolatedSentry.ts
const myCustomInitSentryFunction = () => {
if(!__DEV__) {
Sentry.init( ... ) // 🐞 never called in dev
}}
...
}
So Sentry.wrap always had a warning in dev!
Let's refactor this and deactivate the wrap in dev, not just the init 😁
Also experiencing.
@delphinebugner Thanks! I totally missed that I was also not initing Sentry in __DEV__ mode but was wraping still.
Here is the simple solution if anyone is looking for instead of
if (!__DEV__) {
Sentry.init({
//...other sentry config
});
}
Do this
Sentry.init({
enabled: !__DEV__,
//...other sentry config
})```
Here is the simple solution if anyone is looking for instead of
if (!__DEV__) { Sentry.init({ //...other sentry config }); }Do this
Sentry.init({ enabled: !__DEV__, //...other sentry config })```
wouldn't that mean i wouldn't be able to capture any error on dev also, what if i don't want that?
This is all nice and dandy, but what if I need to call Sentry.init() after I used Sentry.wrap() for my app's root component?
My use case is that I need to dynamically set the dist and release values in Sentry.init() based on over-the-air updates fetched from my server:
- use
Sentry.wrap(App)for my root component, - in a hook in the App, check server for possible OTA updates -> returns
releaseanddist - call
Sentry.init()with thesereleaseanddistvalues
Setting these values after initializing Sentry worked in previous versions (via Sentry.setRelease() / Sentry.setDist()), somehow that functionality was completely removed by now.
I think this should get fixed. @krystofwoldrich can you please reopen?
The issue is that in development sentry is rightfully disabled, which causes it to throw this warning because the calls to .wrap aren't removed. The calls to .wrap shouldn't need to get removed. We shouldn't need to bifurcate exports and imports just because Sentry is throwing a custom warning without doing so. It's extra logic just to silence a warning that shouldn't exist.
The following is the "fix" required to make the warning go away. One would note that it's silly to have to do this:
export default !__DEV__ ? Sentry.wrap(App) : App;