Skip to content

fix(normalize): Treat Infinity as NaN both are non-serializable numbers #13406

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

Merged
merged 9 commits into from
Sep 12, 2024

Conversation

krystofwoldrich
Copy link
Member

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

Copy link
Contributor

github-actions bot commented Aug 16, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.52 KB - -
@sentry/browser - with treeshaking flags 21.3 KB -0.01% -1 B 🔽
@sentry/browser (incl. Tracing) 34.79 KB +0.01% +3 B 🔺
@sentry/browser (incl. Tracing, Replay) 71.24 KB +0.01% +3 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.67 KB -0.01% -1 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 75.58 KB +0.01% +2 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 88.3 KB +0.01% +2 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.14 KB +0.01% +1 B 🔺
@sentry/browser (incl. metrics) 26.83 KB - -
@sentry/browser (incl. Feedback) 39.6 KB - -
@sentry/browser (incl. sendFeedback) 27.19 KB -0.01% -1 B 🔽
@sentry/browser (incl. FeedbackAsync) 31.91 KB +0.02% +4 B 🔺
@sentry/react 25.28 KB +0.01% +1 B 🔺
@sentry/react (incl. Tracing) 37.75 KB +0.01% +1 B 🔺
@sentry/vue 26.72 KB +0.01% +1 B 🔺
@sentry/vue (incl. Tracing) 36.67 KB -0.01% -1 B 🔽
@sentry/svelte 22.66 KB +0.01% +1 B 🔺
CDN Bundle 23.77 KB -0.01% -1 B 🔽
CDN Bundle (incl. Tracing) 36.5 KB - -
CDN Bundle (incl. Tracing, Replay) 70.91 KB -0.01% -2 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 76.22 KB -0.01% -1 B 🔽
CDN Bundle - uncompressed 69.65 KB +0.05% +29 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 108.28 KB +0.03% +29 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 219.94 KB +0.02% +29 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 233.14 KB +0.02% +29 B 🔺
@sentry/nextjs (client) 37.51 KB -0.01% -1 B 🔽
@sentry/sveltekit (client) 35.36 KB +0.01% +1 B 🔺
@sentry/node 120.45 KB -0.01% -1 B 🔽
@sentry/node - without tracing 92.72 KB +0.01% +3 B 🔺
@sentry/aws-serverless 102.43 KB +0.01% +2 B 🔺

View base workflow run

@@ -224,6 +225,10 @@ function stringifyValue(
return '[NaN]';
}

if (typeof value === 'number' && !Number.isFinite(value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, we can improve this even further :D we can combine this with the check above for nan, as (NaN).toString() also returns NaN. And isFinite(NaN) === false. So we can remove this completely:

if (typeof value === 'number' && value !== value) {
      return '[NaN]';
    }

and only keep the new check you added!

@@ -10,5 +10,5 @@ sentryTest('should set extras from multiple consecutive calls', async ({ getLoca
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

expect(eventData.message).toBe('consecutive_calls');
expect(eventData.extra).toMatchObject({ extra: [], Infinity: 2, null: null, obj: { foo: ['bar', 'baz', 1] } });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value under null key is Infinity

@krystofwoldrich krystofwoldrich merged commit 1664dc7 into develop Sep 12, 2024
131 checks passed
@krystofwoldrich krystofwoldrich deleted the kw/normalize-infinity branch September 12, 2024 15:37
@AbhiPrasad
Copy link
Member

@krystofwoldrich this was released with https://github.com/getsentry/sentry-javascript/releases/tag/8.31.0

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

Successfully merging this pull request may close these issues.

3 participants