React-native errors all show 'native code' transaction

In a released React Native project none of my errors in Sentry show any stacktrace.

React-Native 0.39

I have this simple code to cause an error:

  crash() {
    const obj = {};
    obj.something();
  }

When this code is run in dev mode I see the following stack in Sentry:

TypeError: undefined is not a function (evaluating 'obj.something()')
  at crash(/index.android.bundle:1622:9)
  at touchableHandlePress(/index.android.bundle:37894:39)
  at touchableHandlePress([native code])
  at _performSideEffectsForTransition(/index.android.bundle:24063:26)
  ...

When I run this code in a release build all I see it this:

TypeError: undefined is not a function (evaluating 'e.something()')
  at ? ([native code])
  at ? ([native code])
  at ? ([native code])
  at ? ([native code])
  at forEach([native code])
  at ? ([native code])

(I didn’t setup the sourcemaps for both this examples, I’m not sure if this would make a difference).

Does anybody have any experience with using Sentry and React-Native in production?

Yeah, source maps won’t help here – we need a source location, which would appear where [native code] is.

If there’s a bug, it’s that our parser is choking on whatever React Native on Android is presenting as the “function”. If we can’t parse it, we show ? instead.

Any chance you could dump a sample raw stack trace from React Native on Android so we can see what’s going on?

This is the crash log I get from adb:

--------- beginning of crash
12-15 09:09:07.067 16047 16065 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
12-15 09:09:07.067 16047 16065 E AndroidRuntime: Process: com.sentry, PID: 16047
12-15 09:09:07.067 16047 16065 E AndroidRuntime: com.facebook.react.common.JavascriptException: undefined is not a function (evaluating 'e.iets()'), stack:
12-15 09:09:07.067 16047 16065 E AndroidRuntime: value@12:649
12-15 09:09:07.067 16047 16065 E AndroidRuntime: touchableHandlePress@229:1325
12-15 09:09:07.067 16047 16065 E AndroidRuntime: _performSideEffectsForTransition@166:7947
12-15 09:09:07.067 16047 16065 E AndroidRuntime: _receiveSignal@166:6730
12-15 09:09:07.067 16047 16065 E AndroidRuntime: touchableHandleResponderRelease@166:4196
12-15 09:09:07.067 16047 16065 E AndroidRuntime: l@121:59
12-15 09:09:07.067 16047 16065 E AndroidRuntime: o@120:410
12-15 09:09:07.067 16047 16065 E AndroidRuntime: i@120:605
12-15 09:09:07.067 16047 16065 E AndroidRuntime: f@118:151
12-15 09:09:07.067 16047 16065 E AndroidRuntime: p@118:275
12-15 09:09:07.067 16047 16065 E AndroidRuntime: i@123:80
12-15 09:09:07.067 16047 16065 E AndroidRuntime: processEventQueue@118:1331
12-15 09:09:07.067 16047 16065 E AndroidRuntime: s@124:88
12-15 09:09:07.067 16047 16065 E AndroidRuntime: handleTopLevel@124:195
12-15 09:09:07.067 16047 16065 E AndroidRuntime: <unknown>@117:696
12-15 09:09:07.067 16047 16065 E AndroidRuntime: perform@134:617
12-15 09:09:07.067 16047 16065 E AndroidRuntime: batchedUpdates@207:485
12-15 09:09:07.067 16047 16065 E AndroidRuntime: o@126:412
12-15 09:09:07.067 16047 16065 E AndroidRuntime: _receiveRootNodeIDEvent@117:668
12-15 09:09:07.067 16047 16065 E AndroidRuntime: receiveTouches@117:1042
12-15 09:09:07.067 16047 16065 E AndroidRuntime: value@53:2818
12-15 09:09:07.067 16047 16065 E AndroidRuntime: <unknown>@53:1053
12-15 09:09:07.067 16047 16065 E AndroidRuntime: d@53:127
12-15 09:09:07.067 16047 16065 E AndroidRuntime: value@53:1025
12-15 09:09:07.067 16047 16065 E AndroidRuntime:
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:97)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:81)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:751)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:95)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:154)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
12-15 09:09:07.067 16047 16065 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:761)
12-15 09:09:07.074  4844  7393 W ActivityManager:   Force finishing activity com.sentry/.MainActivity

I also put the code on github at https://github.com/FakeYou/react-native-sentry-stacktrace if you want to check it out.

I’m seeing something that might be related.

My react-native app is reporting errors via raven. Everyone is working fine on ios, but not on android. On android everything looks great in development, but in release it always reports the stack as just [native code]. Just one frame.

Besides minification and bundling, the only difference I can see between the two is this small change from adb logcat.

Dev:

12-19 17:35:38.375 31961  2904 W ReactNativeJS: My error message string here
12-19 17:35:38.385 31961  2904 W ReactNativeJS: { [My error message string here]
12-19 17:35:38.385 31961  2904 W ReactNativeJS:   line: 106404,
12-19 17:35:38.385 31961  2904 W ReactNativeJS:   column: 29,
12-19 17:35:38.385 31961  2904 W ReactNativeJS:   sourceURL: 'http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false' }

Release:

12-19 17:29:21.585 30613 30647 W ReactNativeJS: My error message string here
12-19 17:29:21.605 30613 30647 W ReactNativeJS: { [My error message string here] line: 797, column: 2554, sourceURL: 'index.android.bundle' }

I can’t really imagine that the number of linebreaks there is relevant, so please let me know if I can help provide more info in any way.

We are seeing the same behavior at the moment with source maps enabled (both source and source maps are in Sentry as release artifacts)

Error: blah
  at ? ([native code])
  at ? ([native code])
  at ? ([native code])
  at ? ([native code])
  at ? ([native code])
  at forEach([native code])
  at ? ([native code])

Any idea where to start looking?. Happy to help to get this fixed

I’m also struggling with this - any updates? Thanks!

Anyone still struggling with this, you should follow this github issue: https://github.com/getsentry/raven-js/issues/731

A fix for this should be out soon. The issue seems like is with the parsing inside the tracekit library.