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 inspect the repository structure and locate Pages Router/GSSP response handling and relevant tests. Then I’ll reproduce the missing-header path, patch the response propagation/default logic, and run focused plus broader tests.
- Assistant
The initial search produced no matches because the implementation is nested differently than the guessed paths. I’ll enumerate package/test files and then search the whole tracked tree for response adapters and Pages Router terminology.
- Assistant
The likely split is
pages-page-data.ts(invokes GSSP and emulates Node’sres) andpages-page-response.ts(constructs the final FetchResponse). I’ll inspect those contracts and their callers to see where user headers are lost and where response type is known. - Assistant
applyGsspHeadersalready forwardsgsspRes.getHeaders(), so the failure may be specific to deploy mode’s request/response bridge or a later response finalizer. I’ll inspect the exact GSSP invocation, response interface, generated server entry, and production dispatch wrappers before changing behavior. - Assistant
Two concrete defects are visible: HTML forwards user headers but has no GSSP default, while
/_next/dataincorrectly reads a nonexistent/publicly unsupportedgsspRes.headersproperty instead ofgetHeaders(). The reported deploy HTML custom-header loss could additionally occur after entry dispatch, so I’ll trace__createPagesReqRes, deploy adapters, and focused unit-test helpers to reproduce both output paths without adding tests. - Assistant
The existing response unit test confirms ordinary custom headers survive the HTML renderer in isolation, but doesn’t assert Cache-Control or the GSSP default. I’ll inspect adapter semantics and deploy/server response transformations, then run a small temporary reproduction against the renderer to establish the current failing output before patching.
- Assistant
The adapter stores headers correctly, and deploy/production merge functions give the rendered response precedence, so the core loss is in Pages response construction—not the outer server. I’ll inspect the JSON helper signature and current Next-compatible cache constants, then patch both HTML and data responses with case-insensitive
Headershandling so user Cache-Control wins and the default is only a fallback. - Assistant
The exact desired default already exists as
NEVER_CACHE_CONTROL, so I’ll reuse it rather than duplicate policy. I’ll make the HTML renderer apply it only whengsspResexists and no user header is present, while preserving the existing nonce/ISR behavior for non-GSSP pages. For the data route template, I’ll switch fromgsspRes.headerstogetHeaders(), preserve multiple cookies, and apply the same fallback. - Assistant
I’ll implement a shared exported GSSP header applicator. This avoids drift between HTML and
/_next/data, handles arrays and repeated Set-Cookie consistently, and appliesNEVER_CACHE_CONTROLonly after user headers have been copied. I’ll also make the JSON response helper accept all standardHeadersInitforms so the generated entry can safely pass aHeadersobject. - Assistant
Python is unavailable in this environment, so no files were changed. I’ll apply the same deterministic replacements with a temporary Node script and immediately inspect the diff.
- Assistant
The patch now covers the standard HTML and data-envelope paths. Before further edge-case changes, I’ll run the focused response/data tests and type/build checks; this should also validate that generated-entry syntax and
HeadersInittyping are accepted. - Assistant
The test command did not run: the
pnpmshim invoked Corepack’s interactive download prompt, which this environment cannot answer. Dependencies and binaries appear preinstalled, so I’ll invoke the repository-localvpbinary directly and inspect available scripts if needed. - Assistant
Focused tests pass, but they don’t yet exercise the new assertions. I’ll build the package (which type-checks and regenerates
dist), then run a temporary out-of-repository Node script against the built helpers to explicitly reproduce both cases: default GSSP Cache-Control and a user override, including the data-response header handoff. - Assistant
Build, full repository check (format/lint/types), and focused formatting all pass. I’ll now execute the explicit temporary reproduction against built code, then inspect Git status because package builds may rewrite tracked artifacts; only source changes should remain in the submission.
- Assistant
The explicit reproduction now passes for the exact expected default, a user override, custom headers, and repeated cookies through the data envelope. As an additional edge-case safeguard, I’ll ensure ISR policy also never overwrites an already-present Cache-Control (even though Next disallows combining GSSP and GSP), then run the complete unit suite and review the final diff.
- Assistant
The complete unit suite passes: 170 files passed, 1 skipped; 4,755 tests passed and 2 skipped. I’ll perform one final source diff/status review and rerun the focused static check after the last one-line safeguard, then submit if clean.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.