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

misc: split app-render into smaller functions #56611

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Changes from 3 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
6 changes: 3 additions & 3 deletions packages/next/src/lib/metadata/metadata.tsx
Original file line number Diff line number Diff line change
@@ -33,14 +33,14 @@ export function createMetadataComponents({
pathname,
searchParams,
getDynamicParamFromSegment,
appUsingSizeAdjust,
appUsingSizeAdjustment,
errorType,
}: {
tree: LoaderTree
pathname: string
searchParams: { [key: string]: any }
getDynamicParamFromSegment: GetDynamicParamFromSegment
appUsingSizeAdjust: boolean
appUsingSizeAdjustment: boolean
errorType?: 'not-found' | 'redirect'
}): [React.ComponentType, React.ComponentType] {
const metadataContext = {
@@ -110,7 +110,7 @@ export function createMetadataComponents({
IconsMetadata({ icons: metadata.icons }),
])

if (appUsingSizeAdjust) elements.push(<meta name="next-size-adjust" />)
if (appUsingSizeAdjustment) elements.push(<meta name="next-size-adjust" />)

return (
<>
17 changes: 7 additions & 10 deletions packages/next/src/server/app-render/action-handler.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ import {
import RenderResult from '../render-result'
import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external'
import { FlightRenderResult } from './flight-render-result'
import type { ActionResult } from './types'
import type { ActionAsyncStorage } from '../../client/components/action-async-storage.external'
import {
filterReqHeaders,
@@ -37,6 +36,7 @@ import {
NEXT_CACHE_REVALIDATED_TAGS_HEADER,
NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER,
} from '../../lib/constants'
import type { AppRenderContext, GenerateFlight } from './app-render'

function nodeToWebReadableStream(nodeReadable: import('stream').Readable) {
if (process.env.NEXT_RUNTIME !== 'edge') {
@@ -246,21 +246,18 @@ export async function handleAction({
staticGenerationStore,
requestStore,
serverActionsBodySizeLimit,
ctx,
}: {
req: IncomingMessage
res: ServerResponse
ComponentMod: any
page: string
serverActionsManifest: any
generateFlight: (options: {
actionResult: ActionResult
formState?: any
skipFlight: boolean
asNotFound?: boolean
}) => Promise<RenderResult>
generateFlight: GenerateFlight
staticGenerationStore: StaticGenerationStore
requestStore: RequestStore
serverActionsBodySizeLimit?: SizeLimit
ctx: AppRenderContext
}): Promise<
| undefined
| {
@@ -466,7 +463,7 @@ export async function handleAction({
requestStore,
})

actionResult = await generateFlight({
actionResult = await generateFlight(ctx, {
actionResult: Promise.resolve(returnVal),
// if the page was not revalidated, we can skip the rendering the flight tree
skipFlight: !staticGenerationStore.pathWasRevalidated,
@@ -533,7 +530,7 @@ export async function handleAction({
} catch {}
return {
type: 'done',
result: await generateFlight({
result: await generateFlight(ctx, {
skipFlight: false,
actionResult: promise,
asNotFound: true,
@@ -555,7 +552,7 @@ export async function handleAction({

return {
type: 'done',
result: await generateFlight({
result: await generateFlight(ctx, {
actionResult: promise,
// if the page was not revalidated, we can skip the rendering the flight tree
skipFlight: !staticGenerationStore.pathWasRevalidated,
Loading