Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.facebook.react.bridge.ReadableNativeArray cannot be cast to com.facebook.react.bridge.ReadableNativeMap #4165

Closed
5 of 11 tasks
ziga-hvalec opened this issue Oct 11, 2024 · 1 comment · Fixed by #4168
Closed
5 of 11 tasks

Comments

@ziga-hvalec
Copy link

ziga-hvalec commented Oct 11, 2024

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 0.0.0

react-native version: 0.73.8

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

Configuration:

(@sentry/react-native)

Sentry.init({
      dsn: Config.SENTRY_DSN,
      release: `${Platform.OS}@${Config.VERSION_NUMBER}+${Config.BUILD_VERSION}`,
      dist: Config.BUILD_VERSION,
      environment: Config.NAME,
      debug: Config.NAME === 'development',
      appHangTimeoutInterval: 10000,
      enableWatchdogTerminationTracking: false,
      ignoreErrors: IGNORE_ERRORS_LIST,
    });

I have the following issue:

When passing an array to setExtra, setExtras or setContext(possibly others), I get the above error
com.facebook.react.bridge.ReadableNativeArray cannot be cast to com.facebook.react.bridge.ReadableNativeMap
But i only get this on Android. iOS works correctly and also shows data in sentry. This is also only on release build. On debug build both iOS and Android work correctly and i can see context or extra correctly in sentry.

Steps to reproduce:

  • pass array to setExtra or setContext
  • observer crash

Actual result:

App crashes with above error

Expected result:

app not crash :D

@krystofwoldrich
Copy link
Member

Hi @ziga-hvalec,
thank you for the message both setExtras and setContext accept type of { [key: string]: any } which is very permissive, but the underlying native functions expect Record<string, any>. But as you mentioned, passing invalid data should not crash the application.

Until we improve this, please pass arrays like this:

Sentry.setContext("key", {
  any: value,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants