Unverified Commit 1fc4b22d authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Don't send tracing spans if performance.measure doesn't return measurements (#54808)

Fixes #54389.

Old versions of Safari appear to return `undefined` from `performance.measure()` instead of `PerformanceMeasure` values.


Closes WEB-1477
parent cc775795
......@@ -466,19 +466,26 @@ function markHydrateComplete(): void {
'afterHydrate'
)
tracer
.startSpan('navigation-to-hydration', {
startTime: performance.timeOrigin + beforeHydrationMeasure.startTime,
attributes: {
pathname: location.pathname,
query: location.search,
},
})
.end(
performance.timeOrigin +
hydrationMeasure.startTime +
hydrationMeasure.duration
)
if (
process.env.NODE_ENV === 'development' &&
// Old versions of Safari don't return `PerformanceMeasure`s from `performance.measure()`
beforeHydrationMeasure !== undefined &&
hydrationMeasure !== undefined
) {
tracer
.startSpan('navigation-to-hydration', {
startTime: performance.timeOrigin + beforeHydrationMeasure.startTime,
attributes: {
pathname: location.pathname,
query: location.search,
},
})
.end(
performance.timeOrigin +
hydrationMeasure.startTime +
hydrationMeasure.duration
)
}
if (onPerfEntry) {
performance.getEntriesByName('Next.js-hydration').forEach(onPerfEntry)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment