MCPcopy
hub / github.com/vercel/next.js / markHydrateComplete

Function markHydrateComplete

packages/next/src/client/index.tsx:467–517  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

465}
466
467function markHydrateComplete(): void {
468 if (!ST) return
469
470 performance.mark(performanceMarks.afterHydrate) // mark end of hydration
471
472 const hasBeforeRenderMark = performance.getEntriesByName(
473 performanceMarks.beforeRender,
474 'mark'
475 ).length
476 if (hasBeforeRenderMark) {
477 const beforeHydrationMeasure = performance.measure(
478 performanceMeasures.beforeHydration,
479 performanceMarks.navigationStart,
480 performanceMarks.beforeRender
481 )
482
483 const hydrationMeasure = performance.measure(
484 performanceMeasures.hydration,
485 performanceMarks.beforeRender,
486 performanceMarks.afterHydrate
487 )
488
489 if (
490 process.env.NODE_ENV === 'development' &&
491 // Old versions of Safari don't return `PerformanceMeasure`s from `performance.measure()`
492 beforeHydrationMeasure &&
493 hydrationMeasure
494 ) {
495 tracer
496 .startSpan('navigation-to-hydration', {
497 startTime: performance.timeOrigin + beforeHydrationMeasure.startTime,
498 attributes: {
499 pathname: location.pathname,
500 query: location.search,
501 },
502 })
503 .end(
504 performance.timeOrigin +
505 hydrationMeasure.startTime +
506 hydrationMeasure.duration
507 )
508 }
509 }
510
511 if (onPerfEntry) {
512 performance
513 .getEntriesByName(performanceMeasures.hydration)
514 .forEach(onPerfEntry)
515 }
516 clearMarks()
517}
518
519function markRenderComplete(): void {
520 if (!ST) return

Callers

nothing calls this directly

Calls 6

clearMarksFunction · 0.85
markMethod · 0.80
endMethod · 0.65
startSpanMethod · 0.65
measureMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected