vercel/next.js · error
You should not access 'res' after getServerSideProps resolve
Error message
You should not access 'res' after getServerSideProps resolves. Read more: https://nextjs.org/docs/messages/gssp-no-mutating-res
What it means
Development-only runtime guard: while getServerSideProps is awaited, renderToHTMLImpl wraps res in a Proxy whose get trap flips canAccessRes to false once the promise settles. Any later property access on res inside the same render hits the trap and throws this error, catching user code that mutates the response (headers, statusCode) after getServerSideProps has already resolved.
Source
Thrown at packages/next/src/server/render.tsx:1081
props[SERVER_PROPS_ID] = true
}
if (getServerSideProps && !isFallback) {
let data: UnwrapPromise<ReturnType<GetServerSideProps>>
let canAccessRes = true
let resOrProxy = res
let deferredContent = false
if (process.env.NODE_ENV !== 'production') {
resOrProxy = new Proxy<ServerResponse>(res, {
get: function (obj, prop) {
if (!canAccessRes) {
const message =
`You should not access 'res' after getServerSideProps resolves.` +
`\nRead more: https://nextjs.org/docs/messages/gssp-no-mutating-res`
if (deferredContent) {
throw new Error(message)
} else {
warn(message)
}
}
if (typeof prop === 'symbol') {
return ReflectAdapter.get(obj, prop, res)
}
return ReflectAdapter.get(obj, prop, res)
},
})
}
try {
data = await getTracer().trace(
RenderSpan.getServerSideProps,
{View on GitHub (pinned to 89d017eac4)
Solutions
- Do not write to `res` after getServerSideProps resolves; return values via the result object instead.
- Move any `res.setHeader`/`res.end` calls before returning from getServerSideProps.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at packages/next/src/server/render.tsx:1083 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of vercel/next.js@89d017eac4 (2026-08-19).
Data as JSON: /api/errors/fd6bb78834275c98.
Report an issue: GitHub.