vercel/next.js · error
Invalid response ${mocked.res.statusCode}
Error message
Invalid response ${mocked.res.statusCode} What it means
Thrown in NextNodeServer's on-demand revalidation path after it builds a mocked request/response pair and runs the real request handler against the page. The revalidation is only considered successful when the response is 200, carries the x-nextjs-cache: REVALIDATED header, or is a 404 while unstable_onlyGenerated is set. Any other status code reaches this guard, meaning the page handler rejected the revalidation request.
Source
Thrown at packages/next/src/server/next-server.ts:1368
}) {
const mocked = createRequestResponseMocks({
url: urlPath,
headers,
})
const handler = this.getRequestHandler()
await handler(
new NodeNextRequest(mocked.req),
new NodeNextResponse(mocked.res)
)
await mocked.res.hasStreamed
if (
mocked.res.getHeader('x-nextjs-cache') !== 'REVALIDATED' &&
mocked.res.statusCode !== 200 &&
!(mocked.res.statusCode === 404 && opts.unstable_onlyGenerated)
) {
throw new Error(`Invalid response ${mocked.res.statusCode}`)
}
}
public async render(
req: NodeNextRequest | IncomingMessage,
res: NodeNextResponse | ServerResponse,
pathname: string,
query?: NextParsedUrlQuery,
parsedUrl?: NextUrlWithParsedQuery,
internal = false
): Promise<void> {
return super.render(
this.normalizeReq(req),
this.normalizeRes(res),
pathname,
query,
parsedUrl,
internalView on GitHub (pinned to 43273a1d21)
Solutions
- Ensure the mocked/handled response has a valid HTTP status code; check custom server or middleware response handling.
Defensive patterns
Strategy: validation
When it happens
Trigger: A mocked handler produced an invalid response status.
Common situations: Internal invariant when a mock request result has an unexpected status code.
AI-assisted analysis of vercel/next.js@43273a1d21 (2026-08-19).
Data as JSON: /api/errors/b3234129b09c0b6d.
Report an issue: GitHub.