analytics-react-native: Android crash - @ReactMethod setup - promise.resolve(this)

https://github.com/segmentio/analytics-react-native/blob/acd0f2f0dde6ac60a00a6cd593920782a40bc092/packages/core/android/src/main/java/com/segment/analytics/reactnative/core/RNAnalyticsModule.kt#L115

If a case scenario presents itself where the code hits this conditional the promise.resolve(this) causes the following crash:

E/unknown:ReactNative: Exception in native call
    java.lang.RuntimeException: Cannot convert argument of type class com.segment.analytics.reactnative.core.RNAnalyticsModule
        at com.facebook.react.bridge.Arguments.fromJavaArgs(Arguments.java:181)
        at com.facebook.react.bridge.CallbackImpl.invoke(CallbackImpl.java:30)
        at com.facebook.react.bridge.PromiseImpl.resolve(PromiseImpl.java:55)
        at com.segment.analytics.reactnative.core.RNAnalyticsModule.setup(RNAnalyticsModule.kt:116)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:150)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26)
        at android.os.Looper.loop(Looper.java:164)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:225)
        at java.lang.Thread.run(Thread.java:764)

I don’t believe it should be resolving the class instance this - as this is not readable by the react-native bridge. Any idea why it would be resolving promise.resolve(this)?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (6 by maintainers)

Most upvoted comments

@efstathiosntonas oh nice find, that aligns with my implementation as we have our set to false! If their team doesn’t respond soon maybe I will just throw up a PR to see what they say since they aren’t responding here.