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

Flight client navigation error #40861

Merged
merged 3 commits into from Sep 24, 2022
Merged
Changes from 2 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
17 changes: 13 additions & 4 deletions packages/next/server/app-render.tsx
Expand Up @@ -558,9 +558,6 @@ export async function renderToHTMLOrFlight(
? staticGenerationAsyncStorage.getStore()
: staticGenerationAsyncStorage

const { CONTEXT_NAMES } =
ComponentMod.serverHooks as typeof import('../client/components/hooks-server-context')

// don't modify original query object
query = Object.assign({}, query)

Expand All @@ -572,10 +569,17 @@ export async function renderToHTMLOrFlight(
stripInternalQueries(query)
const search = stringifyQuery(query)

// For pages dir, there is only the SSR pass and we don't have the bundled
// React subset. Here we directly import the flight renderer with the
// unbundled React.
// TODO-APP: Is it possible to hard code the flight response here instead of
// rendering it?
const ReactServerDOMWebpack = require('next/dist/compiled/react-server-dom-webpack/writer.browser.server')

// Empty so that the client-side router will do a full page navigation.
const flightData: FlightData = pathname + (search ? `?${search}` : '')
return new FlightRenderResult(
ComponentMod.renderToReadableStream(
ReactServerDOMWebpack.renderToReadableStream(
flightData,
serverComponentManifest,
{
Expand All @@ -585,6 +589,9 @@ export async function renderToHTMLOrFlight(
)
}

const { CONTEXT_NAMES } =
ComponentMod.serverHooks as typeof import('../client/components/hooks-server-context')

// TODO-APP: verify the tree is valid
// TODO-APP: verify query param is single value (not an array)
// TODO-APP: verify tree can't grow out of control
Expand Down Expand Up @@ -1084,6 +1091,8 @@ export async function renderToHTMLOrFlight(
).slice(1),
]

// For app dir, use the bundled version of Fizz renderer (renderToReadableStream)
// which contains the subset React.
const readable = ComponentMod.renderToReadableStream(
flightData,
serverComponentManifest,
Expand Down