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 inspect the repository structure and locate the Pages Router/GSSP response pipeline and related tests, then reproduce the missing-header behavior before making a focused fix.
- Assistant
The initial search produced no matches because the implementation is nested differently than the guessed paths. I’ll enumerate the package/test trees and search repository-wide (excluding generated dependencies) for the GSSP adapter and response mock.
- Assistant
ripgrepis unavailable in this environment, so I’ll usefind/grepinstead and inspect the full source layout. - Assistant
The relevant code appears split between
pages-server-entry.ts(deploy/Worker dispatch),pages-page-data.ts(GSSP execution), andpages-page-response.ts(final FetchResponse). I’ll inspect these interfaces and existing Pages Router tests to identify exactly where GSSP headers are lost. - Assistant
A likely mismatch is visible: the response renderer expects
options.gsspRes, while the deploy entry’s data branch accessesgsspRes.headerseven though the compatibility object exposesgetHeaders(). I’ll inspect the exact page-data result type, header application helper, caller arguments, and tests to confirm both HTML and data paths. - Assistant
HTML custom headers are already forwarded by
applyGsspHeaders, but no default GSSP cache policy is assigned. The/_next/databranch is definitely broken because it checks a nonexistent.headersfield. I’ll inspect fixture definitions and current assertions, then run the smallest relevant tests to establish baseline behavior before editing. - Assistant
I can reproduce the core defect directly with the existing response unit setup: a GSSP response currently has no cache header unless the user supplied one. I’ll run the focused unit tests first, then make the shared renderer apply
NEVER_CACHE_CONTROLonly when GSSP did not setCache-Control, and fix data-response forwarding usinggetHeaders(). - Assistant
The test command was blocked by Corepack’s interactive package-manager download prompt (which this environment cannot answer), not by a test failure. I’ll use the already installed local
vpbinary directly and separately run the reproduction against source or rebuild output. - Assistant
Baseline focused tests pass because they do not assert this compatibility requirement. The fix should cover all GSSP outcomes: normal HTML and
/_next/dataresponses get the default; explicit user cache values win; custom headers/cookies are forwarded. I’ll examine the JSON response helper’s accepted init and redirect/notFound behavior to keep the change scoped and consistent with Next.js. - Assistant
I’ll implement the policy at final response construction, before framework-specific nonce/ISR overrides:
applyGsspHeaderswill seed the canonical default and then user headers overwrite it. For data requests, I’ll gather headers through the actualgetHeaders()API, preserve array-valued cookies, use the GSSP status, and update the JSON helper to correctly merge anyHeadersInitrather than object-spreading it. - Assistant
Python is not installed, so no files were changed. I’ll apply the same exact transformations with Node, asserting each old block exists to avoid accidental edits.
- Assistant
The initial fix is functionally correct, but the generated entry duplicates the canonical string. I’ll check how server-entry dependencies are injected so the shared
NEVER_CACHE_CONTROLconstant can be imported there too, avoiding policy drift. - Assistant
The entry generator already resolves adjacent runtime modules explicitly. I’ll add the cache-control module to that pattern and replace the duplicated literal with the imported canonical constant.
- Assistant
I’ll now apply that cleanup and run formatting/type-aware tests.
- Assistant
Focused unit tests remain green. Since modifying generated deploy code is the key risk, I’ll locate the existing Pages fixture and production-test setup, then run the narrow Pages Router integration file or a filtered subset that exercises both a normal GSSP page and its custom headers in built mode.
- Assistant
There is a reusable production server describe block around line 3080 that already builds the fixture once. I’ll inspect its name and run only its GSSP/data tests via name filtering, which should validate generated entry compilation and live HTTP headers without paying for unrelated suites.
- Assistant
The production setup reuses stale build artifacts if present, so I’ll remove only the generated fixture
distdirectory (not tests), then run the exact production data-GSSP test. This forces compilation of the changed generated entry and verifies the live deploy path. - Assistant
The rebuilt production entry compiled and its live GSSP data endpoint passed. To explicitly confirm the two required values without changing tests, I’ll use a temporary external script to start the production server from that fresh build, fetch
/ssr(default),/ssr-headers(custom non-cache headers plus default), and the GSSP data URL, print headers, then clean up the script. The existing fixture lacks a customCache-Controlpage, so I’ll separately exercise the shared response function with an in-memory GSSP override. - Assistant
That verification attempt failed because
vite-nodeis not installed, and the fallback invokedvpinteractively; the server never ran. Node 22 may load this project’s erasable TypeScript directly, so I’ll invoke the temporary script with Node and retain visible errors. - Assistant
Direct source loading fails because TypeScript source intentionally imports
.jspaths that Vite resolves during tests. The packageddist/prod-server.jscan still host the freshly generated server entry, so I’ll switch only that temporary import. - Assistant
Live deploy verification confirms the default and forwarding. I’ll now verify the explicit override path using Vite’s module runner to load the changed source and call the shared renderer with
getHeaders(): { "Cache-Control": "public, max-age=10" }. This is an external temporary script and will be removed. - Assistant
The override script did not run because this pnpm layout does not expose Vite at the assumed top-level path. I’ll resolve Vite’s actual installed location, then rerun the same temporary check if available.
- Assistant
Vite is encapsulated by
vite-plusrather than available as a standalone module. The reliable verification route is to build the package, invoke the updateddistrenderer, and inspect whether generated dist changes are expected in version control. I’ll build now; if build artifacts are tracked changes, I’ll assess them before submission. - Assistant
The package build succeeds (only pre-existing unresolved virtual-module warnings) and does not alter tracked dist files. I can now run the explicit override check against the rebuilt package output.
- Assistant
One edge-case review found an unnecessary semantic change: the old JSON helper allowed an explicitly supplied
Content-Typeto win because custom headers were spread after the default. To keep this fix narrowly compatible, I’ll preserve that behavior by setting JSON only when absent, while retaining proper support for allHeadersInitforms. - Assistant
The final diff is scoped to the shared GSSP response policy and deploy data forwarding. I’ll rerun focused unit tests after the last adjustment, then run the repository’s static check to catch TypeScript/lint issues.
- Assistant
All focused tests and the full static check pass. As a final review, I’ll confirm only the intended three source files are modified and no temporary/generated fixture artifacts are tracked, then I’ll summarize the checklist 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.