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 { ...@@ -466,19 +466,26 @@ function markHydrateComplete(): void {
'afterHydrate' 'afterHydrate'
) )
tracer if (
.startSpan('navigation-to-hydration', { process.env.NODE_ENV === 'development' &&
startTime: performance.timeOrigin + beforeHydrationMeasure.startTime, // Old versions of Safari don't return `PerformanceMeasure`s from `performance.measure()`
attributes: { beforeHydrationMeasure !== undefined &&
pathname: location.pathname, hydrationMeasure !== undefined
query: location.search, ) {
}, tracer
}) .startSpan('navigation-to-hydration', {
.end( startTime: performance.timeOrigin + beforeHydrationMeasure.startTime,
performance.timeOrigin + attributes: {
hydrationMeasure.startTime + pathname: location.pathname,
hydrationMeasure.duration query: location.search,
) },
})
.end(
performance.timeOrigin +
hydrationMeasure.startTime +
hydrationMeasure.duration
)
}
if (onPerfEntry) { if (onPerfEntry) {
performance.getEntriesByName('Next.js-hydration').forEach(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