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

Clarify variables being used during rendering #36773

Merged
merged 2 commits into from May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/next/server/view-render.tsx
Expand Up @@ -216,16 +216,18 @@ export async function renderToHTML(
ComponentMod,
} = renderOpts

const isFlight = query.__flight__ !== undefined
const flightRouterPath = isFlight ? query.__flight_router_path__ : undefined
timneutkens marked this conversation as resolved.
Show resolved Hide resolved

const hasConcurrentFeatures = !!runtime
const pageIsDynamic = isDynamicRoute(pathname)
const components = Object.keys(ComponentMod.components)
.filter((path) => {
const { __flight__, __flight_router_path__: routerPath } = query
// Rendering part of the page is only allowed for flight data
if (__flight__ !== undefined && routerPath) {
if (flightRouterPath) {
// TODO: check the actual path
const pathLength = path.length
return pathLength >= routerPath.length
return pathLength >= flightRouterPath.length
}
return true
})
Expand Down Expand Up @@ -343,9 +345,8 @@ export async function renderToHTML(
// }
}

// Fall back to default root layout that renders <html> / <head> / <body>
if (!RootLayout) {
// TODO: fallback to our own root layout?
// throw new Error('invariant RootLayout not loaded')
RootLayout = DefaultRootLayout
}

Expand Down Expand Up @@ -412,7 +413,7 @@ export async function renderToHTML(
</FlushEffectContainer>
)

const renderServerComponentData = query.__flight__ !== undefined
const renderServerComponentData = isFlight
if (renderServerComponentData) {
return new RenderResult(
renderToReadableStream(
Expand Down