-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(browser): Fix bug causing unintentional dropping of transactions #12933
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -287,7 +287,13 @@ export function addPerformanceEntries(span: Span): void { | |||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||
performanceEntries.slice(_performanceCursor).forEach((entry: Record<string, any>) => { | ||||||
const startTime = msToSec(entry.startTime); | ||||||
const duration = msToSec(entry.duration); | ||||||
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. | ||||||
// 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, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: any reason for not using
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
); | ||||||
|
||||||
if (op === 'navigation' && transactionStartTime && timeOrigin + startTime < transactionStartTime) { | ||||||
return; | ||||||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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?)
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 🤔