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,6 +466,12 @@ function markHydrateComplete(): void { ...@@ -466,6 +466,12 @@ function markHydrateComplete(): void {
'afterHydrate' 'afterHydrate'
) )
if (
process.env.NODE_ENV === 'development' &&
// Old versions of Safari don't return `PerformanceMeasure`s from `performance.measure()`
beforeHydrationMeasure !== undefined &&
hydrationMeasure !== undefined
) {
tracer tracer
.startSpan('navigation-to-hydration', { .startSpan('navigation-to-hydration', {
startTime: performance.timeOrigin + beforeHydrationMeasure.startTime, startTime: performance.timeOrigin + beforeHydrationMeasure.startTime,
...@@ -479,6 +485,7 @@ function markHydrateComplete(): void { ...@@ -479,6 +485,7 @@ function markHydrateComplete(): void {
hydrationMeasure.startTime + hydrationMeasure.startTime +
hydrationMeasure.duration 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