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 Pages Router/GSSP response handling and its tests, then reproduce the missing-header path before making a focused source change.
- Assistant
The likely seam is
pages-page-response.ts, with Node-compatible response state created inpages-node-compat.tsand final responses assembled by dev/prod servers. I’ll inspect those implementations and existing response tests to understand where GSSP headers are lost and whether data routes share the behavior. - Assistant
The response unit test already verifies arbitrary GSSP headers are merged, suggesting the deployed failure may arise because the real dispatch never supplies
gsspRes, or because build output/runtime differs. I also see cache-control helpers in the source, so I’ll inspect the exact response assembly, call sites, and git state to distinguish an incomplete existing implementation from the bug. - Assistant
The live HTML assembler does preserve
getHeaders(), but it never supplies the required default for GSSP. Custom headers could still be dropped specifically in the generated deploy entry’s data-request branch, where code checks a nonexistent.headersproperty instead ofgetHeaders(). I’ll inspect that generated template and the mutable response class to verify both execution paths. - Assistant
To reproduce without altering tests, I can directly call the response assembler with a GSSP response: today it should return no cache header by default while preserving an explicit one. Before doing so, I’ll inspect
createGsspReqResand the data-response branch in full, since the issue mentions both GSSP andgetStaticPropsresponses and deploy mode may include HTML plus/_next/datarequests. - Assistant
The mutable response confirms
res.setHeaderis retained ingetHeaders(). For HTML, an explicit override already survives unless a nonce policy intentionally forces no-store; for data JSON, the generated deploy code incorrectly reads.headers, so it drops all user headers. The default is absent in both paths. I’ll run the focused unit test as a baseline and use a small temporary script/test invocation to explicitly demonstrate the default isnull, then patch a shared helper so HTML and data responses consistently apply “default unless explicitly set.” - Assistant
The baseline command was blocked by Corepack’s interactive download prompt (not a code failure). I’ll disable that prompt for subsequent runs. Meanwhile, I’ll inspect existing cache constants and relevant test coverage, then make the smallest implementation change; no repository tests will be added per the environment constraint.
- Assistant
A canonical
NEVER_CACHE_CONTROLalready exists with the exact expected value. I’ll use it in the HTML assembler only whengsspResexists and no cache-control was provided. For the deploy data branch, I’ll switch from the nonexistent.headersfield togetHeaders(), preserve array/set-cookie values viaHeaders, and add the same GSSP default before constructing JSON. This keeps explicit user values authoritative and leavesgetStaticPropsISR/static cache semantics unchanged. - Assistant
Rather than duplicate header serialization or the constant inside generated code, I’ll export the existing GSSP-header application function. It will merge Node-style values and add the canonical default only when absent. Both HTML and data response paths can then use it; the JSON helper will also be adjusted to accept a real
Headersobject correctly, preserving repeatedSet-Cookievalues and status codes. - Assistant
Python is unavailable in this environment, so no files were changed. I’ll perform the same guarded replacements with Node, failing explicitly if any expected source block does not match.
- Assistant
The diff exposed one compatibility detail: the old helper deliberately forced HTML content type after merging user headers. Since the shared helper is now content-type-neutral for reuse by JSON responses, each caller must force its own media type. The data helper already does; I’ll restore that behavior explicitly in the HTML caller before testing.
- Assistant
The source adjustment succeeded. This workspace intentionally has no direct
vitestbinary; its configured runner is Vite+ (vp). I’ll run the focused unit projects through that tool, then type-check/build to catch generated-template issues. - Assistant
The test runner started correctly but rejected my malformed reporter argument (
dot=dot); this is tooling invocation only. I’ll rerun without a custom reporter. - Assistant
Focused existing tests pass. To verify the reported behavior explicitly without adding tests, I’ll build the package, invoke the newly shared helper against (1) a default GSSP response and (2) an explicit
Cache-Controloverride, and also verify the JSON response retains aHeadersinstance. Then I’ll inspect generated artifacts and git status so only intended source files are submitted. - Assistant
The build completed and the direct runtime verification confirmed all three key cases: canonical default, explicit override preservation, and forwarding into data JSON with status/content type intact. I’ll now run formatting/type/lint checks plus adjacent Pages Router data/response tests, then review the final diff for edge cases such as case-insensitive headers, arrays, cookies, and non-GSSP static responses.
- Assistant
Formatting found only an import-order/style issue in
pages-page-response.ts; because the commands were chained, checks/tests did not yet run. I’ll apply the repository formatter to the three changed files and rerun the full validation sequence. - Assistant
All repository checks passed (format, lint, and type checking across the workspace), as did 32 adjacent unit tests. I’ll perform a final diff/status review and inspect the generated import/template lines after formatting. I’ll also confirm no test or build artifacts are tracked and reason through header precedence before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.