Unverified Commit ef5af614 authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

[ppr] PFPR Debugging Fixes (#71390)

This fixes a few bugs with the Partial Fallback Prerendering
experimental debugging mode where the hot reloader was incorrectly
triggering a postpone to occur as well as the logic for turning on
postponing during a debugging session.
parent eca4c8d3
......@@ -2,7 +2,7 @@ import type { ReactNode } from 'react'
import { useCallback, useEffect, startTransition, useMemo, useRef } from 'react'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import formatWebpackMessages from '../internal/helpers/format-webpack-messages'
import { usePathname, useRouter } from '../../navigation'
import { useRouter } from '../../navigation'
import {
ACTION_BEFORE_REFRESH,
ACTION_BUILD_ERROR,
......@@ -36,6 +36,7 @@ import { extractModulesFromTurbopackMessage } from '../../../../server/dev/extra
import { REACT_REFRESH_FULL_RELOAD_FROM_ERROR } from '../shared'
import type { HydrationErrorState } from '../internal/helpers/hydration-error-info'
import type { DebugInfo } from '../types'
import { useUntrackedPathname } from '../../navigation-untracked'
export interface Dispatcher {
onBuildOk(): void
......@@ -598,7 +599,10 @@ export default function HotReload({
)
const router = useRouter()
const pathname = usePathname()
// We don't want access of the pathname for the dev tools to trigger a dynamic
// access (as the dev overlay will never be present in production).
const pathname = useUntrackedPathname()
const appIsrManifestRef = useRef<Record<string, false | number>>({})
const pathnameRef = useRef(pathname)
......@@ -612,7 +616,7 @@ export default function HotReload({
const appIsrManifest = appIsrManifestRef.current
if (appIsrManifest) {
if (pathname in appIsrManifest) {
if (pathname && pathname in appIsrManifest) {
const indicatorHiddenAt = Number(
localStorage?.getItem('__NEXT_DISMISS_PRERENDER_INDICATOR')
)
......
......@@ -2971,9 +2971,13 @@ export default abstract class Server<
// We pass `undefined` as rendering a fallback isn't resumed
// here.
postponed: undefined,
fallbackRouteParams: isProduction
? getFallbackRouteParams(pathname)
: null,
fallbackRouteParams:
// If we're in production of we're debugging the fallback
// shell then we should postpone when dynamic params are
// accessed.
isProduction || isDebugFallbackShell
? getFallbackRouteParams(pathname)
: null,
}),
{
routeKind: RouteKind.APP_PAGE,
......@@ -3179,7 +3183,10 @@ export default abstract class Server<
isRoutePPREnabled &&
cacheEntry.value?.kind === CachedRouteKind.APP_PAGE &&
cacheEntry.isFallback &&
!isOnDemandRevalidate
!isOnDemandRevalidate &&
// When we're debugging the fallback shell, we don't want to regenerate
// the route shell.
!isDebugFallbackShell
) {
scheduleOnNextTick(async () => {
try {
......
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