Skip to content

Conversation

mydea
Copy link
Member

@mydea mydea commented Jul 10, 2025

Related to #16846

This rewrites timestampInSeconds to avoid side effects.

As a part of this, I also streamlined this a bit to remove special handling for missing timeOrigin. If that is missing, we just fall back to using dateTimestampInSeconds, instead of doing some custom handling of timeOrigin - IMHO that should not be any less accurate, as otherwise we are currently mixing performance.now with Date.now() which is likely not necessarily accurate either.

@mydea mydea requested review from timfish and AbhiPrasad July 10, 2025 11:58
@mydea mydea self-assigned this Jul 10, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Performance API Time Origin Handling Error

The condition !performance.timeOrigin incorrectly treats a valid performance.timeOrigin value of 0 (representing the Unix epoch) as missing. This causes an unnecessary fallback to the less accurate dateTimestampInSeconds instead of utilizing the more precise Performance API. The previous check performance.timeOrigin == undefined correctly distinguished between missing and valid 0 values.

packages/core/src/utils/time.ts#L36-L37

// using Date.now() to compute the starting time.
if (!performance?.now || !performance.timeOrigin) {

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.81 kB -0.01% -1 B 🔽
@sentry/browser - with treeshaking flags 22.54 kB +0.02% +4 B 🔺
@sentry/browser (incl. Tracing) 39.67 kB +0.03% +11 B 🔺
@sentry/browser (incl. Tracing, Replay) 77.79 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.73 kB +0.01% +5 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 82.49 kB -0.01% -2 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 94.6 kB -0.01% -7 B 🔽
@sentry/browser (incl. Feedback) 40.5 kB +0.03% +12 B 🔺
@sentry/browser (incl. sendFeedback) 28.5 kB +0.04% +10 B 🔺
@sentry/browser (incl. FeedbackAsync) 33.39 kB +0.02% +5 B 🔺
@sentry/react 25.6 kB +0.06% +14 B 🔺
@sentry/react (incl. Tracing) 41.66 kB +0.03% +12 B 🔺
@sentry/vue 28.27 kB +0.03% +8 B 🔺
@sentry/vue (incl. Tracing) 41.48 kB +0.04% +14 B 🔺
@sentry/svelte 23.83 kB -0.03% -6 B 🔽
CDN Bundle 25.36 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing) 39.63 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing, Replay) 75.57 kB -0.01% -2 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 81.02 kB -0.01% -4 B 🔽
CDN Bundle - uncompressed 74.08 kB +0.01% +4 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 117.7 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 231.62 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 244.44 kB - -
@sentry/nextjs (client) 43.3 kB +0.04% +16 B 🔺
@sentry/sveltekit (client) 40.13 kB +0.05% +18 B 🔺
@sentry/node 167.87 kB +0.01% +11 B 🔺
@sentry/node - without tracing 100.58 kB -0.01% -5 B 🔽
@sentry/aws-serverless 128.7 kB +0.01% +5 B 🔺

View base workflow run

@mydea mydea merged commit 7be5f79 into develop Jul 10, 2025
173 checks passed
@mydea mydea deleted the fn/avoid-time-side-effect branch July 10, 2025 14:15
antonis added a commit to getsentry/sentry-react-native that referenced this pull request Aug 28, 2025
antonis added a commit to getsentry/sentry-react-native that referenced this pull request Aug 28, 2025
* chore(ci): v7: Handle GH runner image deprecations

* chore(deps): v7: update Android SDK to v8.20.0

* Adds changelog

* Set specific xcode version for expo (see expo/expo#36830)

* Bump Javascript SDK to 9.44.2

* Bump Javascript SDK to 10.4.0 and rename deprecated base client getsentry/sentry-javascript#17071

* Renames logger getsentry/sentry-javascript#16901

* Bump Javascript SDK to 10.7.0

* Adds changelog

* Sets skipLibCheck to true in ts3.8 typecheck

* Fixes fake timers jest issue after getsentry/sentry-javascript#16890

* Fixes lint issue

* Apply suggestions from code review

Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com>

* Update yarn.lock

---------

Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com>
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.

2 participants