Android Release Build stack showing wrong location (even in the sentry-test example project)
OS:
- [ ] Windows
- [x] MacOS
- [ ] Linux
Platform:
- [ ] iOS
- [x] Android
Output of node -v && npm -v && npm ls --prod --depth=0
v8.1.2
5.0.3
[email protected] /Users/work/workspace/chefdadi/examples/react-native/AwesomeProject
├── [email protected]
├── [email protected]
└── [email protected]
Sentry.config(
'https://__DSN__',
{
logLevel: SentryLog.Verbose
}
).install();
I have following issue: Stacktrace line number off in Android release build. It's about ~20 lines off.
Steps to reproduce:
- Clone the sentry-test project (https://github.com/getsentry/examples/tree/71b60dd1a451ffa6b20c7959137608ba7faf3787)
- In render() of index.android.js, add the following code:
try {
throw Error('my error');
} catch (e) {
Sentry.captureException(e);
}
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native Sentry example
</Text>
<Button
style={{ fontSize: 20, color: 'green' }}
styleDisabled={{ color: 'red' }}
onPress={() => this._setVersion()}
accessibilityLabel={'set version'}
title="Set version"
/>
<Button
style={{ fontSize: 20, color: 'green' }}
styleDisabled={{ color: 'red' }}
onPress={() => this._setRelease()}
accessibilityLabel={'set release'}
title="Set release"
/>
<Button
style={{ fontSize: 20, color: 'green' }}
styleDisabled={{ color: 'red' }}
onPress={() => this._setDist()}
accessibilityLabel={'set dist'}
title="Set dist"
/>
...
- Build release build of Android and run.
Actual result:
Stack trace on sentry pointing to this._setDist() which is ~20 lines below the real exception.
<Button
style={{ fontSize: 20, color: 'green' }}
styleDisabled={{ color: 'red' }}
---> onPress={() => this._setDist()}
accessibilityLabel={'set dist'}
title="Set dist"
/>
Expected result:
- Stacktrace should point to the
throw Error()line.
Hey, thank you for reporting. We had this issue already a few times but it still seems to be a problem with react-native itself see: https://github.com/facebook/react-native/issues/6946
I will keep this open to having a reference.
Thank you! Are you aware of any work arounds? I am not sure if this is related to versioning or how often it repros but essentially it’s making the entire android error reporting to sentry obsolete..
Also here is a min repro in a release android build:
console.log(new Error('my error').stack)
The stack will show wrong line/column number in the bundle file.
Just adding an older issue for documentation purposes: https://github.com/facebook/react-native/issues/13685
There is a workaround for this, the error is not in Sentry, you need to update JavaScriptCore on Android to make source map work. see: https://github.com/react-community/jsc-android-buildscripts