Skip to content

Commit

Permalink
Merge rsc queries handling (#35545)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
huozhi and kodiakhq[bot] committed Mar 23, 2022
1 parent 9fef0d5 commit 2cf6696
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 34 deletions.
Expand Up @@ -56,7 +56,6 @@ export default async function middlewareSSRLoader(this: any) {
buildManifest,
reactLoadableManifest,
serverComponentManifest: ${isServerComponent} ? rscManifest : null,
isServerComponent: ${isServerComponent},
config: ${stringifiedConfig},
buildId: ${JSON.stringify(buildId)},
})
Expand Down
Expand Up @@ -25,7 +25,6 @@ export function getRender({
buildManifest,
reactLoadableManifest,
serverComponentManifest,
isServerComponent,
config,
buildId,
}: {
Expand All @@ -39,7 +38,6 @@ export function getRender({
buildManifest: BuildManifest
reactLoadableManifest: ReactLoadableManifest
serverComponentManifest: any | null
isServerComponent: boolean
config: NextConfig
buildId: string
}) {
Expand Down Expand Up @@ -109,10 +107,6 @@ export function getRender({
const requestHandler = server.getRequestHandler()

return async function render(request: NextRequest) {
const { nextUrl: url } = request
const { searchParams } = url
const query = Object.fromEntries(searchParams)

// Preflight request
if (request.method === 'HEAD') {
// Hint the client that the matched route is a SSR page.
Expand All @@ -123,21 +117,6 @@ export function getRender({
})
}

const renderServerComponentData = isServerComponent
? query.__flight__ !== undefined
: false

const serverComponentProps =
isServerComponent && query.__props__
? JSON.parse(query.__props__)
: undefined

// Extend the render options.
server.updateRenderOpts({
renderServerComponentData,
serverComponentProps,
})

const extendedReq = new WebNextRequest(request)
const extendedRes = new WebNextResponse()
requestHandler(extendedReq, extendedRes)
Expand Down
19 changes: 11 additions & 8 deletions packages/next/server/render.tsx
Expand Up @@ -231,8 +231,6 @@ export type RenderOptsPartial = {
resolvedUrl?: string
resolvedAsPath?: string
serverComponentManifest?: any
renderServerComponentData?: boolean
serverComponentProps?: any
distDir?: string
locale?: string
locales?: string[]
Expand Down Expand Up @@ -451,7 +449,6 @@ export async function renderToHTML(
getStaticPaths,
getServerSideProps,
serverComponentManifest,
serverComponentProps,
isDataReq,
params,
previewProps,
Expand Down Expand Up @@ -505,11 +502,17 @@ export async function renderToHTML(
return ''
}

let { renderServerComponentData } = renderOpts
if (isServerComponent && query.__flight__) {
renderServerComponentData = true
delete query.__flight__
}
let renderServerComponentData = isServerComponent
? query.__flight__ !== undefined
: false

const serverComponentProps =
isServerComponent && query.__props__
? JSON.parse(query.__props__ as string)
: undefined

delete query.__flight__
delete query.__props__

const callMiddleware = async (method: string, args: any[], props = false) => {
let results: any = props ? {} : []
Expand Down
4 changes: 0 additions & 4 deletions packages/next/server/web-server.ts
Expand Up @@ -203,8 +203,4 @@ export default class NextWebServer extends BaseServer {
components: result,
}
}

public updateRenderOpts(renderOpts: Partial<BaseServer['renderOpts']>) {
Object.assign(this.renderOpts, renderOpts)
}
}

0 comments on commit 2cf6696

Please sign in to comment.