GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(browser): Fix bug causing unintentional dropping of transactions by lforst · Pull Request #12933 · getsentry/sentry-javascript

Conversation

@lforst

@lforst lforst commented Jul 16, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

We saw instances of pageload transactions being dropped because they contained spans with negative durations (timestamp < start_timestamp).

After investigating it seems like performance entries by the browser are emitted with a negative duration. We could only observe this happening in Chrome.

The particular environment this could be (flakily) reproduced is on Chrome, for the scaffold Next.js app, with the Sentry SDK and Replay installed. The negative duration span that was recorded was for the replay worker resource.

Other people also seem to be running into this but so far I don't really understand why the duration is negative and how we would mitigate this properly. This PR is more of a hot-fix than anything else.

Attempts to fix: #12914

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andreiborza and purplecandy reacted with laugh emoji
All reactions
  • 😄 2 reactions
@andreiborza

andreiborza commented Jul 16, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

_ No description provided. _

To add some context, this happens for me with the replay integration and particularly for the spans for the request to the worker blob, and only in Chrome.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Luca Forstner
.
e96b4af
@lforst
lforst force-pushed the lforst-prevent-dropping-of-transactions branch from 5ef066c to e96b4af Compare July 17, 2024 08:24
@github-actions

github-actions Bot commented Jul 17, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
@sentry/browser 22.3 KB (0%)
@sentry/browser (incl. Tracing) 33.69 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing, Replay) 69.78 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.08 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 74.17 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 86.49 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 88.37 KB (+0.01% 🔺)
@sentry/browser (incl. metrics) 26.59 KB (0%)
@sentry/browser (incl. Feedback) 38.98 KB (0%)
@sentry/browser (incl. sendFeedback) 26.93 KB (0%)
@sentry/browser (incl. FeedbackAsync) 31.54 KB (0%)
@sentry/react 25.06 KB (0%)
@sentry/react (incl. Tracing) 36.76 KB (+0.02% 🔺)
@sentry/vue 26.41 KB (0%)
@sentry/vue (incl. Tracing) 35.57 KB (+0.02% 🔺)
@sentry/svelte 22.44 KB (0%)
CDN Bundle 23.52 KB (0%)
CDN Bundle (incl. Tracing) 35.47 KB (+0.01% 🔺)
CDN Bundle (incl. Tracing, Replay) 69.88 KB (+0.01% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.14 KB (+0.01% 🔺)
CDN Bundle - uncompressed 69 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 104.94 KB (+0.02% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 216.72 KB (+0.01% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 229.44 KB (+0.01% 🔺)
@sentry/nextjs (client) 36.62 KB (+0.02% 🔺)
@sentry/sveltekit (client) 34.35 KB (+0.02% 🔺)
@sentry/node 111.28 KB (0%)
@sentry/node - without tracing 88.73 KB (0%)
@sentry/aws-serverless 97.87 KB (0%)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andreiborza
andreiborza reviewed Jul 17, 2024
View reviewed changes
Comment thread packages/browser-utils/src/metrics/browserMetrics.ts Outdated
// There is a SO post attempting to explain this, but it leaves one with open questions: https://stackoverflow.com/questions/23191918/peformance-getentries-and-negative-duration-display
// The way we clamp the value is probably not accurate, since we have observed this happen for things that may take a while to load, like for example the replay worker.
// TODO: Investigate why this happens and how to properly mitigate. For now, this is a workaround to prevent transactions being dropped due to negative duration spans.
entry.duration < 0 ? 0 : entry.duration,

@andreiborza andreiborza Jul 17, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

l: any reason for not using Math.max?

Suggested change
entry.duration < 0 ? 0 : entry.duration,
Math.max(0, entry.duration),

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@lforst lforst Jul 17, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I have a theory that performance is better for the inline if but can change

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Luca Forstner
math.max
90f86d3
@lforst
lforst marked this pull request as ready for review July 17, 2024 11:16
Lms24
Lms24 approved these changes Jul 17, 2024
View reviewed changes

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just a comment on the comment but it looks like a reasonable guard.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/browser-utils/src/metrics/browserMetrics.ts
const duration = msToSec(
// Inexplicibly, Chrome sometimes emits a negative duration. We need to work around this.
// There is a SO post attempting to explain this, but it leaves one with open questions: https://stackoverflow.com/questions/23191918/peformance-getentries-and-negative-duration-display
// The way we clamp the value is probably not accurate, since we have observed this happen for things that may take a while to load, like for example the replay worker.

@Lms24 Lms24 Jul 17, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

does the worker take a while to load though? I'd imagine creating the blob should be fairly fast since the code ships with the already loaded JS SDK bundle by default? My guess yesterday was the opposite: that it's too fast and therefore causing weird timing problems 😅
(maybe this is also blob-specific?)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@lforst lforst Jul 17, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think it loaded in something like 4ms when we tested it (which was locally in dev mode). So not too fast. Even if it loaded "too fast" a negative duration doesn't make sense in my eyes 🤔

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lforst
lforst merged commit e710f3b into develop Jul 17, 2024
@lforst
lforst deleted the lforst-prevent-dropping-of-transactions branch July 17, 2024 12:34
@andreiborza andreiborza mentioned this pull request Jul 29, 2024
chore(react): Bump to latest sentry react sdk sentry-demos/empower#540
Merged
@angeloreale angeloreale mentioned this pull request Aug 9, 2024
[Snyk] Upgrade @sentry/nextjs from 8.17.0 to 8.19.0 dupipcom/hypnos#29
Closed
This was referenced Aug 9, 2024
[Snyk] Upgrade @sentry/react from 7.118.0 to 8.19.0 Stanislav1975/win11React#4
Open
[Snyk] Upgrade @sentry/node from 6.17.4 to 8.19.0 Stanislav1975/shields#596
Open
@q1blue q1blue mentioned this pull request Aug 9, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.19.0 https-quantumblockchainai-atlassian-net/ossinsight#802
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Aug 11, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.19.0 FengShangWuQi/fengshangwuqi.github.io#1914
Closed
@angeloreale angeloreale mentioned this pull request Aug 15, 2024
[Snyk] Upgrade @sentry/nextjs from 8.17.0 to 8.20.0 dupipcom/hypnos#30
Merged
@q1blue q1blue mentioned this pull request Aug 16, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.20.0 https-quantumblockchainai-atlassian-net/ossinsight#807
Open
@wkylin wkylin mentioned this pull request Aug 19, 2024
[Snyk] Upgrade @sentry/react from 8.18.0 to 8.20.0 wkylin/pro-react-admin#383
Closed
This was referenced Aug 22, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.21.0 https-quantumblockchainai-atlassian-net/ossinsight#814
Open
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.22.0 https-quantumblockchainai-atlassian-net/ossinsight#816
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Aug 25, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.22.0 FengShangWuQi/fengshangwuqi.github.io#1916
Closed
This was referenced Aug 27, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.23.0 https-quantumblockchainai-atlassian-net/ossinsight#820
Open
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.24.0 https-quantumblockchainai-atlassian-net/ossinsight#833
Open
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.25.0 https-quantumblockchainai-atlassian-net/ossinsight#835
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Sep 1, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.25.0 FengShangWuQi/fengshangwuqi.github.io#1918
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@andreiborza andreiborza andreiborza left review comments
@Lms24 Lms24 Lms24 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Pageloads traces aren't being captured by sentry/nextjs

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@lforst @andreiborza @Lms24
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.