ISSUE DESCRIPTION Pages Router: gssp/getStaticProps responses missing default and…
- User
ISSUE DESCRIPTION
Pages Router: gssp/getStaticProps responses missing default and user-set
Cache-ControlheaderThis issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext
mainvs Next.jsv16.2.6, 2026-05-22).Problem
Pages Router gssp responses lack
Cache-Controlheaders. Tests expect the defaultprivate, no-cache, no-store, max-age=0, must-revalidatefor gssp pages and custom values set viares.setHeader('Cache-Control', ...), but vinext returnsnull. The default header is not applied and usersetHeadercalls are dropped.codeExpected: "private, no-cache, no-store, max-age=0, must-revalidate" Received: nullEstimated Impact
~2 test failures across the deploy suite.
Affected Test Suites
test/e2e/getserversideprops/test/index.test.ts(2 failures)
Recommendation
-
Reproduce first in vinext's own test suite. Add a Pages Router gssp page and assert the response carries the default
Cache-Controlheader; add a second page that overrides it viares.setHeaderand assert the override sticks. -
Emit the default gssp Cache-Control. When serving a gssp response in deploy mode, set
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidateunless the user set it explicitly. -
Preserve
res.setHeaderoverrides. Make sure headers set during gssp dispatch are forwarded to the final HTTP response.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I’ll first map the repository and locate the Pages Router/GSSP response pipeline and relevant tests, then reproduce the missing-header behavior before modifying the implementation.
- Assistant
The initial search was inadvertently limited to directories that do not match this repository’s layout closely enough. I’ll inspect the package/test trees and search the entire tracked codebase for the routing and header abstractions.
- Assistant
ripgrepis unavailable in the environment, so I’ll use recursivegrepand enumerate the deeper source tree. The likely implementation is generated through Vite virtual modules, so I’ll include templates and plugin directories. - Assistant
Existing coverage already verifies custom GSSP headers in the main Pages Router integration path, suggesting the defect is specific to production/deploy finalization rather than the Node-compatible response object itself. I’ll inspect page-data execution, response construction, and production dispatch together with the relevant test setup.
- Assistant
The current fixture confirms generic custom headers in both development and likely shared rendering, but it does not assert
Cache-Control, and the reported deployment adapter may apply special cache policy afterward. I’ll isolate the exact GSSP result propagation and every final response/cache-control transformation. - Assistant
The Node-compatible object retains headers correctly through
getHeaders(). The likely gap is either that deploy’s generated entry reads a nonexistent.headersproperty (seen in the fallback branch) or that GSSP identity is lost before finalization. I’ll inspect those exact blocks and deployment response handling without truncation. - Assistant
For HTML responses,
applyGsspHeadersworks but no default GSSP cache policy is added. For data requests, the code incorrectly checksgsspRes.headers, which the response abstraction does not expose, explaining dropped user headers there. The deploy-suite tests may exercise HTML and data URLs differently; I’ll inspect the helper and adapter finalizers, then reproduce both variants against the production fixture. - Assistant
No adapter layer removes response headers. The implementation needs two coordinated fixes: assign Next.js’s default private no-cache policy only for GSSP when the user did not set
Cache-Control, and forwardgetHeaders()(plus status) for/_next/dataresponses. Before editing, I’ll run the focused existing production test with temporary fixture modification avoided; the current/ssrendpoint is sufficient to reproduce the missing default, while/ssr-headersverifies general propagation. - Assistant
The focused invocation timed out because it selected the entire large integration file and used an unsupported Vitest-style flag. The source already centralizes the exact value as
NEVER_CACHE_CONTROL, so I’ll reuse that constant rather than duplicate it. I’ll also inspect unit-test conventions around response finalization, then patch the two paths with ordering that preserves explicit user values. - Assistant
I’ll implement framework policy in the response finalizer, after applying GSSP headers so an explicit case-insensitive
Cache-Controlwins. For data responses, I’ll construct a realHeadersobject fromgetHeaders(), preserving repeated cookies and GSSP status; the JSON helper will accept all standardHeadersInitforms instead of object-spreading them. The generated server entry will import the shared constant. - Assistant
Python is unavailable, so no files were changed by that command. I’ll apply the same exact replacements using Node, then update the generated-entry import and data-response block.
- Assistant
The core HTML policy and generic
HeadersInitsupport are now patched. I’ll add the shared cache-control module path to the entry generator and replace the broken.headersaccess withgetHeaders(), handling arrays andSet-Cookiecorrectly and carrying the GSSP status into the JSON response. - Assistant
The diff now covers normal HTML and data GSSP responses. One edge case remains: a GSSP that calls
res.end()returns before the normal renderer, so it should also receive the default policy while preserving explicit headers; redirects/notFound similarly currently discard GSSP headers entirely. I’ll centralize finalization in page-data execution so all GSSP short-circuit responses inherit user headers and default policy, then avoid duplicating behavior where practical. First I’ll inspect available local test runner binaries and run a narrowly filtered test if supported. - Assistant
I’ll validate the implementation in layers: first run focused existing tests for GSSP custom headers and production data responses, then build/type-check the package. The tests’ setup performs real server builds, so I’ll allow sufficient timeout and run one worker to avoid fixture races.
- Assistant
The focused integration tests pass, including production generation of the modified entry. To explicitly verify the reported header (rather than only regressions around it), I’ll invoke the generated production
renderPageentry directly against/ssrand/ssr-headers, inspecting response headers. Then I’ll temporarily alter only the generated bundle at runtime—not repository tests/fixtures—to simulateres.setHeader("Cache-Control", custom)if needed. First I’ll inspect the built entry’s exported API and retained artifacts. - Assistant
The built entry is available. I’ll call it with its SSR manifest and minimal execution context, first for HTML and then the normalized data route options, to capture the exact cache/header behavior now produced.
- Assistant
The first direct call exposed a harness mistake, not an implementation failure:
middlewareHeadersmust be aHeadersobject because CSP extraction calls.get(). I’ll rerun with the correct type. - Assistant
The direct production reproduction now confirms the default exact value on HTML and data responses, while preserving existing custom headers/status. To verify an explicit cache override end-to-end, I’ll temporarily inject one line into the existing fixture, rebuild via the focused production integration setup, inspect the generated response, and restore the fixture immediately. This does not modify or add any test and will leave no tracked fixture change.
- Assistant
The end-to-end production check confirms both requirements: the exact default is emitted, and an explicit
public, max-age=3600survives on both HTML and data responses with status/custom headers intact. The fixture was restored and only three source files remain changed. I’ll now run formatting, package-wide type/lint checks, and relevant unit/integration tests; then review the final diff for edge cases. - Assistant
Formatting passes. The combined command stopped because
vp checkdoes not support the test runner’s--projectflag, so the tests in that chain did not run. I’ll run repository checks with their supported syntax, followed by the focused integration selection separately. - Assistant
All repository checks pass and the focused integration set passes. I’ve considered the
res.end()edge: that path represents a fully user-owned response and already preserves all explicitly set headers; changing it to inject framework headers could diverge from Node’s short-circuit semantics and is outside the two reported standard GSSP render failures. Redirect/notFound behavior is likewise separate. I’ll run the package build to ensure generated-entry imports bundle correctly, then inspect the final diff/status and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.