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

Invariant Violation when passing an object with Infinity into addBreadcrumb #4024

Open
4 of 11 tasks
thomasttvo opened this issue Aug 14, 2024 · 5 comments
Open
4 of 11 tasks

Comments

@thomasttvo
Copy link

thomasttvo commented Aug 14, 2024

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

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

SDK version: 5.29.0

react-native version: 0.73.5

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

Calling addBreadcrumb on Android with an Infinity value throws an error, which may crash the app in certain cases. We don't usually mean to call it with an Infinity value, but it's hard to control what's being logged automatically.

I think at the very least, Sentry should wrap its methods around try/catch internally and log the errors to avoid them affecting the main application?

try {
  Sentry.addBreadcrumb({
     category: 'redux.action',
     type: 'info',
     data: { x: Infinity },
  });
} catch(e) {
  console.log(e)
}
Invariant Violation: [{"timestamp":1723673438.573,"category":"redux.action","type":"info","data":{"x":"<<Infinity>>"},"level":"info"}] is not usable as a native method argument, js engine: hermes
@krystofwoldrich
Copy link
Member

Hi @thomasttvo,
thank you for the message,

we recommend adding know data structures to the breadcrumb, but regardless that, the addBreadcrumbs function should not throw.

@krystofwoldrich
Copy link
Member

@krystofwoldrich
Copy link
Member

After running the sample code I'm not getting the same error but malformed JS call.

It looks like RN serialization error.

@thomasttvo
Copy link
Author

thomasttvo commented Aug 16, 2024

After running the sample code I'm not getting the same error but malformed JS call.

It looks like RN serialization error.

I believe the malformed JS is caused by RN catching the uncaught error and doing some processing with it. If you wrap it around a try/catch, you'll get the error I mentioned

@krystofwoldrich
Copy link
Member

Thank you, I did that, but the malformed JS is a native error and is not captured by the JS try/catch.

krystofwoldrich added a commit to getsentry/sentry-javascript that referenced this issue Sep 12, 2024
…rs (#13406)

RN SDK uses the normalize function before passing data over the RN
Bridge, which only accepts serializable data.

Infinity causes ->
getsentry/sentry-react-native#4024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: In Progress
Development

No branches or pull requests

3 participants