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