Unverified Commit 76ddf785 authored by Jan Kassens's avatar Jan Kassens Committed by GitHub

Remove dead NextNodeServer.renderHTML (#100284)

# Human Notes

This deletes some code that appears to be dead but would otherwise need
to be updated as we refactor other code nearby to pull out `request` and
`response` from inner functions.

# AI

## Summary

`NextNodeServer.renderHTML` (and its abstract declaration on
`BaseServer`) has had no callers since #81944, which removed the last
call site. Nothing else in `packages/` or `test/` references it.

This removes the method along with everything only it used:

- `lazyRenderAppPage` in `route-modules/app-page/module.render.ts`.
`lazyPrerenderAppPage` stays because export uses it.
- The `NextNodeServerSpan.renderHTML` trace span constant. It is no
longer emitted and is not in either span allowlist.
- `renderOpts.isPossibleServerAction`. `renderHTML` was its only reader.
The App Router renderer reads `isPossibleServerAction` from its render
context, not from `renderOpts`, so the Node and Edge templates no longer
need to write it. The Pages `RenderOpts` field is unchanged.

This is not public API. The `next()` custom-server wrapper (`NextServer`
in `server/next.ts`) never forwarded `renderHTML`; it only exposes the
already-deprecated `render`, `renderToHTML`, `renderError`,
`renderErrorToHTML` and `render404`. The method is `protected` on both
server classes, and the only way to reach it is by subclassing
`NextNodeServer` from `next/dist`. An override there has not run since
#81944, because nothing calls the method. The span name is not in the
span allowlists or the docs, and has not been emitted since the same PR.

There is no behavior change. This also means the App page render inputs
have one fewer producer to keep in sync when they change.

## Verification

- `tsc --noEmit` for `packages/next`: no errors
- ESLint and Prettier on the changed files
- Not run: e2e tests (the deleted code had no callers, so CI covers it)

<!-- NEXT_JS_LLM -->

---------
Co-authored-by: 's avatarClaude Opus 5.5 <noreply@anthropic.com>
parent da8f4e92
...@@ -946,7 +946,6 @@ export function createAppPageEntrypoint({ ...@@ -946,7 +946,6 @@ export function createAppPageEntrypoint({
isDraftMode, isDraftMode,
botType, botType,
isOnDemandRevalidate, isOnDemandRevalidate,
isPossibleServerAction,
assetPrefix: routeModule.getAssetPrefixForRender( assetPrefix: routeModule.getAssetPrefixForRender(
routerServerContext, routerServerContext,
nextConfig.assetPrefix nextConfig.assetPrefix
......
...@@ -108,7 +108,6 @@ async function requestHandler( ...@@ -108,7 +108,6 @@ async function requestHandler(
// INJECT_RAW:cacheHandlerRegistration // INJECT_RAW:cacheHandlerRegistration
const serverActionRequestMetadata = getServerActionRequestMetadata(baseReq) const serverActionRequestMetadata = getServerActionRequestMetadata(baseReq)
const { isPossibleServerAction } = serverActionRequestMetadata
const userAgent = req.headers.get('User-Agent') || '' const userAgent = req.headers.get('User-Agent') || ''
const botType = getBotType(userAgent) const botType = getBotType(userAgent)
const { isOnDemandRevalidate } = checkIsOnDemandRevalidate( const { isOnDemandRevalidate } = checkIsOnDemandRevalidate(
...@@ -166,7 +165,6 @@ async function requestHandler( ...@@ -166,7 +165,6 @@ async function requestHandler(
botType, botType,
isDraftMode: false, isDraftMode: false,
isOnDemandRevalidate, isOnDemandRevalidate,
isPossibleServerAction,
assetPrefix: nextConfig.assetPrefix, assetPrefix: nextConfig.assetPrefix,
nextConfigOutput: nextConfig.output, nextConfigOutput: nextConfig.output,
crossOrigin: nextConfig.crossOrigin, crossOrigin: nextConfig.crossOrigin,
......
...@@ -115,7 +115,6 @@ export interface RenderOptsPartial { ...@@ -115,7 +115,6 @@ export interface RenderOptsPartial {
cacheLifeProfiles: import('../config-shared').ResolvedCacheLifeProfiles cacheLifeProfiles: import('../config-shared').ResolvedCacheLifeProfiles
staticPageGenerationTimeout: number staticPageGenerationTimeout: number
isOnDemandRevalidate?: boolean isOnDemandRevalidate?: boolean
isPossibleServerAction?: boolean
setCacheStatus?: (status: ServerCacheStatus, htmlRequestId: string) => void setCacheStatus?: (status: ServerCacheStatus, htmlRequestId: string) => void
setIsrStatus?: (key: string, value: boolean | undefined) => void setIsrStatus?: (key: string, value: boolean | undefined) => void
setReactDebugChannel?: ( setReactDebugChannel?: (
......
...@@ -37,7 +37,6 @@ import type { ClientReferenceManifest } from '../build/webpack/plugins/flight-ma ...@@ -37,7 +37,6 @@ import type { ClientReferenceManifest } from '../build/webpack/plugins/flight-ma
import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin' import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin'
import type { PagesAPIRouteMatch } from './route-matches/pages-api-route-match' import type { PagesAPIRouteMatch } from './route-matches/pages-api-route-match'
import type { RouteMatch } from './route-matches/route-match' import type { RouteMatch } from './route-matches/route-match'
import type { RouteMatch as AppRenderRouteMatch } from './route-modules/app-page/module'
import type { RouteDefinition } from './route-definitions/route-definition' import type { RouteDefinition } from './route-definitions/route-definition'
import type { AppPageRouteDefinition } from './route-definitions/app-page-route-definition' import type { AppPageRouteDefinition } from './route-definitions/app-page-route-definition'
import type { AppRouteRouteDefinition } from './route-definitions/app-route-route-definition' import type { AppRouteRouteDefinition } from './route-definitions/app-route-route-definition'
...@@ -420,15 +419,6 @@ export default abstract class Server< ...@@ -420,15 +419,6 @@ export default abstract class Server<
match: PagesAPIRouteMatch match: PagesAPIRouteMatch
): Promise<boolean> ): Promise<boolean>
protected abstract renderHTML(
req: ServerRequest,
res: ServerResponse,
pathname: string,
query: NextParsedUrlQuery,
renderOpts: LoadedRenderOpts,
routeMatch: AppRenderRouteMatch
): Promise<RenderResult>
protected abstract getIncrementalCache(options: { protected abstract getIncrementalCache(options: {
requestHeaders: Record<string, undefined | string | string[]> requestHeaders: Record<string, undefined | string | string[]>
}): Promise<import('./lib/incremental-cache').IncrementalCache> }): Promise<import('./lib/incremental-cache').IncrementalCache>
......
...@@ -55,7 +55,6 @@ enum NextNodeServerSpan { ...@@ -55,7 +55,6 @@ enum NextNodeServerSpan {
proxyRequest = 'NextNodeServer.proxyRequest', proxyRequest = 'NextNodeServer.proxyRequest',
runApi = 'NextNodeServer.runApi', runApi = 'NextNodeServer.runApi',
render = 'NextNodeServer.render', render = 'NextNodeServer.render',
renderHTML = 'NextNodeServer.renderHTML',
imageOptimizer = 'NextNodeServer.imageOptimizer', imageOptimizer = 'NextNodeServer.imageOptimizer',
getPagePath = 'NextNodeServer.getPagePath', getPagePath = 'NextNodeServer.getPagePath',
getRoutesManifest = 'NextNodeServer.getRoutesManifest', getRoutesManifest = 'NextNodeServer.getRoutesManifest',
......
...@@ -25,12 +25,6 @@ import type { ...@@ -25,12 +25,6 @@ import type {
import type { Params } from './request/params' import type { Params } from './request/params'
import type { MiddlewareRouteMatch } from '../shared/lib/router/utils/middleware-route-matcher' import type { MiddlewareRouteMatch } from '../shared/lib/router/utils/middleware-route-matcher'
import type { RouteMatch } from './route-matches/route-match' import type { RouteMatch } from './route-matches/route-match'
import type {
DevRenderContext,
RouteMatch as AppRenderRouteMatch,
} from './route-modules/app-page/module'
import { createDevRenderContext } from './route-modules/app-page/dev-render-context'
import { getServerActionRequestMetadata } from './lib/server-action-request-meta'
import type { IncomingMessage, ServerResponse } from 'http' import type { IncomingMessage, ServerResponse } from 'http'
import type { ParsedUrlQuery } from 'querystring' import type { ParsedUrlQuery } from 'querystring'
import type { ParsedUrl } from '../shared/lib/router/utils/parse-url' import type { ParsedUrl } from '../shared/lib/router/utils/parse-url'
...@@ -39,7 +33,6 @@ import type { WaitUntil } from './after/builtin-request-context' ...@@ -39,7 +33,6 @@ import type { WaitUntil } from './after/builtin-request-context'
import type { AppPageModule } from './route-modules/app-page/module' import type { AppPageModule } from './route-modules/app-page/module'
import type { AppRouteModule } from './route-modules/app-route/module.compiled' import type { AppRouteModule } from './route-modules/app-route/module.compiled'
import type { ErrorModule } from './load-default-error-components' import type { ErrorModule } from './load-default-error-components'
import type { PagesModule } from './route-modules/pages/module.compiled'
import fs from 'fs' import fs from 'fs'
import { join, relative } from 'path' import { join, relative } from 'path'
...@@ -73,7 +66,6 @@ import type { ...@@ -73,7 +66,6 @@ import type {
MiddlewareRoutingItem, MiddlewareRoutingItem,
RequestContext, RequestContext,
NormalizedRouteManifest, NormalizedRouteManifest,
LoadedRenderOpts,
RouteHandler, RouteHandler,
NextEnabledDirectories, NextEnabledDirectories,
BaseRequestHandler, BaseRequestHandler,
...@@ -117,15 +109,6 @@ import { createRequestResponseMocks, MockedResponse } from './lib/mock-request' ...@@ -117,15 +109,6 @@ import { createRequestResponseMocks, MockedResponse } from './lib/mock-request'
import { NEXT_RSC_UNION_QUERY } from '../client/components/app-router-headers' import { NEXT_RSC_UNION_QUERY } from '../client/components/app-router-headers'
import { signalFromNodeResponse } from './web/spec-extension/adapters/next-request' import { signalFromNodeResponse } from './web/spec-extension/adapters/next-request'
import { loadManifest } from './load-manifest.external' import { loadManifest } from './load-manifest.external'
import {
lazyPrerenderAppPage,
lazyRenderAppPage,
} from './route-modules/app-page/module.render'
import {
parseRequestHeaders,
type ParsedRequestHeaders,
} from './route-modules/app-page/parse-request-headers'
import { lazyRenderPagesPage } from './route-modules/pages/module.render'
import { interopDefault } from '../lib/interop-default' import { interopDefault } from '../lib/interop-default'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path' import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin' import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin'
...@@ -648,117 +631,6 @@ export default class NextNodeServer extends BaseServer< ...@@ -648,117 +631,6 @@ export default class NextNodeServer extends BaseServer<
return true return true
} }
protected async renderHTML(
req: NodeNextRequest,
res: NodeNextResponse,
pathname: string,
query: NextParsedUrlQuery,
renderOpts: LoadedRenderOpts,
routeMatch: AppRenderRouteMatch
): Promise<RenderResult> {
return getTracer().trace(NextNodeServerSpan.renderHTML, async () =>
this.renderHTMLImpl(req, res, pathname, query, renderOpts, routeMatch)
)
}
private async renderHTMLImpl(
req: NodeNextRequest,
res: NodeNextResponse,
pathname: string,
query: NextParsedUrlQuery,
renderOpts: LoadedRenderOpts,
routeMatch: AppRenderRouteMatch
): Promise<RenderResult> {
if (process.env.NEXT_MINIMAL) {
throw new Error(
'Invariant: renderHTML should not be called in minimal mode'
)
// the `else` branch is needed for tree-shaking
} else {
// Due to the way we pass data by mutating `renderOpts`, we can't extend the
// object here but only updating its `nextFontManifest` field.
// https://github.com/vercel/next.js/blob/df7cbd904c3bd85f399d1ce90680c0ecf92d2752/packages/next/server/render.tsx#L947-L952
renderOpts.nextFontManifest = this.nextFontManifest
if (this.enabledDirectories.app && renderOpts.isAppPath) {
const renderAppPage =
!renderOpts.supportsDynamicResponse &&
!renderOpts.isDraftMode &&
!renderOpts.isPossibleServerAction
? lazyPrerenderAppPage
: lazyRenderAppPage
const dev: DevRenderContext | undefined = createDevRenderContext(
req,
process.env.__NEXT_DEV_SERVER
? this.getServerComponentsHmrCache()
: undefined
)
const parsedRequestHeaders: ParsedRequestHeaders = parseRequestHeaders(
req.headers,
{
isRoutePPREnabled:
renderOpts.experimental.isRoutePPREnabled === true,
previewModeId: renderOpts.previewProps?.previewModeId,
}
)
const result = await renderAppPage(
req,
res,
req.url,
pathname,
query,
// This code path does not service revalidations for unknown param
// shells. As a result, we don't need to pass in the unknown params.
null,
renderOpts as LoadedRenderOpts<AppPageModule>,
dev,
{
buildId: this.buildId,
deploymentId: this.deploymentId,
clientAssetToken: this.nextConfig.supportsImmutableAssets
? ''
: this.deploymentId,
},
routeMatch,
parsedRequestHeaders,
getServerActionRequestMetadata(req)
)
if ('error' in result) {
throw result.error
}
return result
} else {
// TODO: re-enable this once we've refactored to use implicit matches
// throw new Error('Invariant: render should have used routeModule')
return lazyRenderPagesPage(
req.originalRequest,
res.originalResponse,
pathname,
query,
renderOpts as LoadedRenderOpts<PagesModule>,
{
buildId: this.buildId,
deploymentId: this.deploymentId,
clientAssetToken: this.nextConfig.supportsImmutableAssets
? undefined
: this.deploymentId,
customServer: this.serverOptions.customServer || undefined,
},
{
isFallback: false,
isDraftMode: renderOpts.isDraftMode,
developmentNotFoundSourcePage: getRequestMeta(
req,
'developmentNotFoundSourcePage'
),
}
)
}
}
}
protected async imageOptimizer( protected async imageOptimizer(
req: NodeNextRequest, req: NodeNextRequest,
res: NodeNextResponse, res: NodeNextResponse,
......
import type { import type { AppPagePrerender } from '../../app-render/app-render'
AppPagePrerender,
AppPageRender,
} from '../../app-render/app-render'
function getAppPageModule(): typeof import('./module.compiled') { function getAppPageModule(): typeof import('./module.compiled') {
if (process.env.NEXT_MINIMAL) { if (process.env.NEXT_MINIMAL) {
throw new Error("Can't use lazyRenderAppPage in minimal mode") throw new Error("Can't use lazyPrerenderAppPage in minimal mode")
} else { } else {
return require('./module.compiled') as typeof import('./module.compiled') return require('./module.compiled') as typeof import('./module.compiled')
} }
} }
export const lazyRenderAppPage: AppPageRender = (...args) => {
const render: AppPageRender = getAppPageModule().renderToHTMLOrFlight
return render(...args)
}
export const lazyPrerenderAppPage: AppPagePrerender = (...args) => { export const lazyPrerenderAppPage: AppPagePrerender = (...args) => {
const prerender: AppPagePrerender = getAppPageModule().prerenderToHTMLOrFlight const prerender: AppPagePrerender = getAppPageModule().prerenderToHTMLOrFlight
return prerender(...args) return prerender(...args)
......
...@@ -135,7 +135,6 @@ async function readNormalizedNFT(next, name) { ...@@ -135,7 +135,6 @@ async function readNormalizedNFT(next, name) {
"/node_modules/@swc/helpers/*", "/node_modules/@swc/helpers/*",
"/node_modules/client-only/*", "/node_modules/client-only/*",
"/node_modules/detect-libc/*", "/node_modules/detect-libc/*",
"/node_modules/next/dist/build/adapter/setup-node-env.external.js",
"/node_modules/next/dist/build/define-env.js", "/node_modules/next/dist/build/define-env.js",
"/node_modules/next/dist/build/duration-to-string.js", "/node_modules/next/dist/build/duration-to-string.js",
"/node_modules/next/dist/build/get-supported-browsers.js", "/node_modules/next/dist/build/get-supported-browsers.js",
...@@ -170,7 +169,6 @@ async function readNormalizedNFT(next, name) { ...@@ -170,7 +169,6 @@ async function readNormalizedNFT(next, name) {
"/node_modules/next/dist/compiled/@vercel/detect-agent/index.js", "/node_modules/next/dist/compiled/@vercel/detect-agent/index.js",
"/node_modules/next/dist/compiled/async-retry/index.js", "/node_modules/next/dist/compiled/async-retry/index.js",
"/node_modules/next/dist/compiled/async-sema/index.js", "/node_modules/next/dist/compiled/async-sema/index.js",
"/node_modules/next/dist/compiled/busboy/index.js",
"/node_modules/next/dist/compiled/bytes/index.js", "/node_modules/next/dist/compiled/bytes/index.js",
"/node_modules/next/dist/compiled/ci-info/index.js", "/node_modules/next/dist/compiled/ci-info/index.js",
"/node_modules/next/dist/compiled/commander/index.js", "/node_modules/next/dist/compiled/commander/index.js",
...@@ -192,11 +190,7 @@ async function readNormalizedNFT(next, name) { ...@@ -192,11 +190,7 @@ async function readNormalizedNFT(next, name) {
"/node_modules/next/dist/compiled/is-animated/index.js", "/node_modules/next/dist/compiled/is-animated/index.js",
"/node_modules/next/dist/compiled/is-docker/index.js", "/node_modules/next/dist/compiled/is-docker/index.js",
"/node_modules/next/dist/compiled/is-wsl/index.js", "/node_modules/next/dist/compiled/is-wsl/index.js",
"/node_modules/next/dist/compiled/jsonwebtoken/index.js",
"/node_modules/next/dist/compiled/nanoid/index.cjs", "/node_modules/next/dist/compiled/nanoid/index.cjs",
"/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js",
"/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",
"/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js",
"/node_modules/next/dist/compiled/p-limit/index.js", "/node_modules/next/dist/compiled/p-limit/index.js",
"/node_modules/next/dist/compiled/p-queue/index.js", "/node_modules/next/dist/compiled/p-queue/index.js",
"/node_modules/next/dist/compiled/path-browserify/index.js", "/node_modules/next/dist/compiled/path-browserify/index.js",
...@@ -210,9 +204,7 @@ async function readNormalizedNFT(next, name) { ...@@ -210,9 +204,7 @@ async function readNormalizedNFT(next, name) {
"/node_modules/next/dist/compiled/send/index.js", "/node_modules/next/dist/compiled/send/index.js",
"/node_modules/next/dist/compiled/source-map/source-map.js", "/node_modules/next/dist/compiled/source-map/source-map.js",
"/node_modules/next/dist/compiled/stacktrace-parser/stack-trace-parser.cjs.js", "/node_modules/next/dist/compiled/stacktrace-parser/stack-trace-parser.cjs.js",
"/node_modules/next/dist/compiled/string-hash/index.js",
"/node_modules/next/dist/compiled/strip-ansi/index.js", "/node_modules/next/dist/compiled/strip-ansi/index.js",
"/node_modules/next/dist/compiled/superstruct/index.cjs",
"/node_modules/next/dist/compiled/tar/index.min.js", "/node_modules/next/dist/compiled/tar/index.min.js",
"/node_modules/next/dist/compiled/text-table/index.js", "/node_modules/next/dist/compiled/text-table/index.js",
"/node_modules/next/dist/compiled/watchpack/watchpack.js", "/node_modules/next/dist/compiled/watchpack/watchpack.js",
...@@ -382,25 +374,10 @@ async function readNormalizedNFT(next, name) { ...@@ -382,25 +374,10 @@ async function readNormalizedNFT(next, name) {
"/node_modules/next/dist/trace/report/to-telemetry.js", "/node_modules/next/dist/trace/report/to-telemetry.js",
"/node_modules/next/dist/trace/shared.js", "/node_modules/next/dist/trace/shared.js",
"/node_modules/next/dist/trace/trace.js", "/node_modules/next/dist/trace/trace.js",
"/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js",
"/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.js",
"/node_modules/react-dom/cjs/react-dom-server.browser.production.js",
"/node_modules/react-dom/cjs/react-dom-server.edge.production.js",
"/node_modules/react-dom/cjs/react-dom-server.node.production.js",
"/node_modules/react-dom/cjs/react-dom.production.js", "/node_modules/react-dom/cjs/react-dom.production.js",
"/node_modules/react-dom/index.js", "/node_modules/react-dom/index.js",
"/node_modules/react-dom/server.browser.js",
"/node_modules/react-dom/server.edge.js",
"/node_modules/react-dom/server.node.js",
"/node_modules/react-dom/static.node.js",
"/node_modules/react/cjs/react-compiler-runtime.production.js",
"/node_modules/react/cjs/react-jsx-dev-runtime.production.js",
"/node_modules/react/cjs/react-jsx-runtime.production.js",
"/node_modules/react/cjs/react.production.js", "/node_modules/react/cjs/react.production.js",
"/node_modules/react/compiler-runtime.js",
"/node_modules/react/index.js", "/node_modules/react/index.js",
"/node_modules/react/jsx-dev-runtime.js",
"/node_modules/react/jsx-runtime.js",
"/node_modules/semver/*", "/node_modules/semver/*",
"/node_modules/sharp/*", "/node_modules/sharp/*",
"/node_modules/styled-jsx/*", "/node_modules/styled-jsx/*",
......
...@@ -153,11 +153,6 @@ describe('Production Usage', () => { ...@@ -153,11 +153,6 @@ describe('Production Usage', () => {
file.includes('next/dist/shared/lib/page-path/normalize-page-path.js') file.includes('next/dist/shared/lib/page-path/normalize-page-path.js')
) )
).toBe(true) ).toBe(true)
expect(
serverTrace.files.some((file) =>
file.includes('next/dist/server/render.js')
)
).toBe(true)
expect( expect(
serverTrace.files.some((file) => serverTrace.files.some((file) =>
file.includes('next/dist/server/load-components.js') file.includes('next/dist/server/load-components.js')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment