Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ppr] PFPR Debugging Fixes #71390

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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')
)
Expand Down
15 changes: 11 additions & 4 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
Loading