Capítulo 440 de 456
How adapters invoke Next.js's build output entrypoints at runtime, with distinct interfaces for the Node.js runtime and the (deprecated) Edge runtime.
runtime: 'nodejs'): handler(req: IncomingMessage, res: ServerResponse, ctx: { waitUntil?, requestMeta? }).requestMeta helper fields: relativeProjectDir, hostname (for absolute URL construction), revalidate (custom async revalidate implementation), render404 (custom 404 rendering for Pages Router notFound: true).runtime: 'edge', deprecated): handler(request: Request, ctx: { waitUntil?, signal?, requestMeta? }): Promise<Response>.output.edgeRuntime: canonical metadata for edge outputs — modulePath, entryKey, handlerExport (currently always 'handler'); use this instead of deriving keys from filenames.globalThis._ENTRIES: global edge entry registry read using entryKey after loading modulePath's chunks.await handler(req, res, {
requestMeta: {
relativeProjectDir: '.',
hostname: '127.0.0.1',
revalidate: async ({ urlPath, headers, opts }) => {
// platform-specific revalidate implementation
},
render404: async (req, res, parsedUrl, setHeaders) => {
// platform-specific 404 rendering implementation
},
},
})
requestMeta em vez de depender de internals.const entry = await globalThis._ENTRIES[output.edgeRuntime.entryKey]
const handler = entry[output.edgeRuntime.handlerExport]
await handler(request, ctx)
output.edgeRuntime.edgeRuntime.entryKey/handlerExport.IncomingMessage/ServerResponse vs. Request/Response), mas ambos seguem o padrão handler(..., ctx).output.edgeRuntime existe em qualquer output com runtime: 'edge', dando a metadata exata pra invocação correta.edgeRuntime quando runtime: 'edge'.ctx.waitUntil/requestMeta usado aqui.