sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Android Release Build stack showing wrong location (even in the sentry-test example project)

Open chefkefu opened this issue 9 years ago • 5 comments

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.

chefkefu avatar Oct 10 '17 21:10 chefkefu

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.

HazAT avatar Oct 11 '17 13:10 HazAT

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..

chefkefu avatar Oct 11 '17 16:10 chefkefu

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.

chefkefu avatar Oct 11 '17 23:10 chefkefu

Just adding an older issue for documentation purposes: https://github.com/facebook/react-native/issues/13685

HazAT avatar Oct 20 '17 06:10 HazAT

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

HazAT avatar Aug 13 '18 11:08 HazAT