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.Expected: "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) usinggit statusorgit diffcommands. 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 I’ll reproduce the missing-header behavior, implement header propagation and the default policy at the narrowest appropriate layer, and run focused plus broader tests.
- Assistant
The initial search returned no matches because the implementation is likely nested under the package layout not covered as expected (or generated naming differs). I’ll inspect the package and test trees directly, including repository guidance that may define local conventions.
- Assistant
The production Pages Router path is concentrated in
pages-page-data.ts(GSSP invocation) andpages-page-response.ts(final HTTP response). I’ll read those sections and their focused tests to determine where user response headers are represented and where deploy-mode finalization currently loses them. - Assistant
The final HTML renderer already calls
applyGsspHeaders, so the defect may be in the response shim’s header storage rather than final response construction—or in a separate deploy data-response branch. I’ll inspect the exact GSSP invocation, response shim,applyGsspHeaders, and deploy/prod dispatch wiring without broad output truncation. - Assistant
The renderer’s existing propagation uses
getHeaders()correctly, but no default is applied for GSSP. The custom override should already survive HTML rendering unless a deploy adapter strips it, so I’ll verify the shim semantics and generated entry call arguments, then reproduce with unit-level calls and/or the existing production fixture. - Assistant
There is already a production fixture
ssr-headers.tsx, ideal for reproducing the custom-header path without altering tests. I’ll inspect that fixture and production suite/server helpers, then run the targeted existing production test or a direct request against its fixture. - Assistant
The existing dev test confirms propagation there, while the issue is explicitly deploy mode. I’ll inspect the production test setup and run the production Pages Router subset to capture current GSSP headers. This also distinguishes a deploy adapter issue from the renderer’s missing default.
- Assistant
The production suite currently does not assert
ssr-headers, explaining why custom propagation regressions escaped. At source level custom headers are propagated, but deploy mode may use builtdistcode that is stale during tests; still, the robust fix belongs in final response construction. I’ll run the relevant production suite once before editing and use a focused test name that starts its shared production server. - Assistant
The package-manager command was blocked by Corepack’s interactive download prompt, so I’ll use the repository’s installed
vpbinary directly for later verification. The source review reveals two concrete gaps: HTML GSSP gets no default, and the_next/datashort-circuit separately copies only user headers and therefore also gets no default. I’ll inspect the JSON helper and existing cache constants, then centralize GSSP header finalization so both HTML and data responses obey “user override first, default otherwise.” - Assistant
The data branch has an additional bug: it reads
gsspRes.headers, but the shim exposes headers viagetHeaders(), so user headers are indeed dropped there. I’ll implement an exported GSSP-header applicator using the existing canonicalNEVER_CACHE_CONTROL, use it for both HTML and data responses, make the JSON helper acceptHeaderssafely, and ensure nonce/ISR policy does not overwrite explicit GSSP cache control. - Assistant
Python is unavailable in this environment, so no files were changed. I’ll apply the same precise transformations with Node, including guards that fail if expected source blocks do not match.
- Assistant
The implementation is now in place. Before expensive integration builds, I’ll run fast focused unit tests and type/build checks. I’ll also create a temporary (untracked, then removed) direct reproduction script that exercises the actual shim plus shared applicator for both default and explicit
Cache-Control, satisfying the requested before/after behavior without modifying tests. - Assistant
Focused tests and the full package build/type emission pass. I’ll now execute the temporary reproduction against built deploy artifacts: create actual Pages
req/res, simulate a GSSP with no header and one withres.setHeader, apply finalization, and verify both HTML-style headers and_next/dataresponse construction. Then I’ll remove the script. - Assistant
The built-artifact reproduction now passes for all four cases (default/custom × HTML/data). Next I’ll run the existing production Pages Router integration test that starts the real deploy server; its shared fixture includes the GSSP routes and validates response adaptation end-to-end.
- Assistant
The real production server integration passes. I’ll now inspect deploy/Cloudflare response finalization for any explicit cache-header filtering (the reported deploy suite may bypass the Node production adapter), and clean up the small policy branch before running formatting/lint checks.
- Assistant
No deploy adapter strips
Cache-Control; TPR explicitly preserves it. The final source policy is now cleanly nested so only non-GSSP responses receive nonce/ISR policies. I’ll run formatter and lint/type-aware checks on the changed files, followed by the focused tests again after the cleanup. - Assistant
Formatting found one issue (likely import wrapping); lint/tests did not run because the command short-circuited. I’ll apply the repository formatter to that source file, inspect its changes, then rerun all checks.
- Assistant
Formatting, lint, and focused tests all pass. I’ll do a final diff review for accidental scope changes, run the existing GSSP header/status test (which validates custom headers and cookies) and rerun package build after formatting. Then I’ll check repository cleanliness before submission.
- Assistant
Final verification is complete:
- Reproduced reported error: Source inspection and the temporary built-artifact reproduction confirmed the missing default; it also exposed the data-route bug reading nonexistent
gsspRes.headers. - Confirmed fix: The temporary reproduction passed default and custom policies for both HTML and
_next/data; existing dev custom-header and real production-server tests also passed. - Edge cases considered: Explicit cache policy wins case-insensitively; cookies/other GSSP headers still forward; JSON content type remains authoritative; nonce/ISR policy applies only to non-GSSP;
Headersinputs now work in data responses. - Affected tests run: 22 focused unit tests passed, both focused Pages Router integrations passed, formatter/linter reported no errors, and the package build/type generation completed successfully.
Only the three intended source files are modified, with no temporary files or test changes. I’ll submit the solution.
- Reproduced reported error: Source inspection and the temporary built-artifact reproduction confirmed the missing default; it also exposed the data-route bug reading nonexistent
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.