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.
Interface
No new interfaces are introduced.
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 statusor 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 start by exploring the repository structure and locating the gSSP / Cache-Control handling code related to this issue.
- Assistant
There's a
cache-headersmodule — I'll inspect that and search the codebase for gSSP / Cache-Control handling. - Assistant
Let me look at cache-headers.ts, cache-control.ts, pages-page-response.ts, pages-page-data.ts and related files.
- Assistant
rg is not available, let me use grep instead.
- Assistant
I'll open the core gSSP response and cache-control modules next.
- Assistant
The earlier cat was truncated — I'll open the Cache-Control section of pages-page-response.ts next.
- Assistant
I'll check createGsspReqRes /
__createPagesReqResand how gSSP headers are tracked. - Assistant
Let me look at pages-node-compat and the tests related to pages-page-response. Also look at how data routes handle cache headers.
- Assistant
I'll inspect pages-data-route and related tests for Cache-Control expectations.
- Assistant
I spot a likely bug: data requests read
gsspRes.headersinstead ofgetHeaders(). Checking types and how Next.js sets default Cache-Control. - Assistant
Checking AGENTS.md and e2e notes for getServerSideProps Cache-Control behavior.
- Assistant
I'll check how we distinguish gSSP renders and how app-page-response applies default Cache-Control.
- Assistant
Checking cloudflare/TPR and prod-server for Cache-Control stripping, and searching deploy suite notes.
- Assistant
Looking for Next.js deploy suite references and e2e pages-router Cache-Control tests.
- Assistant
I'll inspect the pages-router gSSP header tests and how the fixture sets Cache-Control.
- Assistant
pages-server-entry is generated code — I'll inspect how headers are forwarded there.
- Assistant
Reading the ssr-headers fixture and reviewing recent Cache-Control commits.
- Assistant
Inspecting how the dev server applies gSSP headers and Cache-Control.
- Assistant
I'll dig into Next.js getServerSideProps e2e test expectations and any local Next.js checkout.
- Assistant
Searching the pnpm store and Next.js package for the gSSP Cache-Control test.
- Assistant
Inspecting Next.js pages-handler Cache-Control logic for gSSP.
- Assistant
Let me look at sendRenderResult / when cacheControl is set for gSSP
- Assistant
I have a clear fix plan: emit default gSSP
Cache-Control, stop overwriting user overrides, and fix data-route header forwarding viagetHeaders(). - Assistant
Let me apply the fix to pages-page-response.ts first.
- Assistant
Updating
applyGsspHeadersand Cache-Control logic next. - Assistant
Fixing the typo in the comment, then updating pages-data-route and the data request path.
- Assistant
Updating pages-server-entry data-request path and its imports.
- Assistant
I'll update the import and the data-request header path in pages-server-entry.
- Assistant
The pages-server-entry is a generator that outputs template string code. I need to edit the template string carefully.
- Assistant
Now I'll fix the data request path so it uses getHeaders and applies default Cache-Control.
- Assistant
The edit only applies to currently displayed lines — navigating to the data-request block.
- Assistant
Now I can edit.
- Assistant
Checking whether
buildNextDataJsonResponsehandles aHeadersobject ininit.headers. - Assistant
Updating
buildNextDataJsonResponseto handleHeaderscorrectly. - Assistant
Need to fix buildNextDataJsonResponse to handle Headers. When spreading Headers into object, it fails. Also multi set-cookie won't work with plain object. Headers constructor accepts HeadersInit which...
- Assistant
Updating the dev-server path for default gSSP Cache-Control.
- Assistant
Let me update dev-server to import NEVER_CACHE_CONTROL and apply it.
- Assistant
I'll track whether gSSP ran and apply the default Cache-Control in the dev server.
- Assistant
Now mark when gSSP ran andapply.default.
- Assistant
I'll add a flag
let ranGssp = falsewhen gSSP runs successfully (i.e., enters the block and doesn't short-circuit with redirect/notFound/end). - Assistant
Now add Cache-Control default in data and HTML paths.
- Assistant
I'll add a helper function locally to check if Cache-Control is in headers.
- Assistant
Now the HTML headers for dev-server.
- Assistant
Also need to handle scriptNonce with gSSP - if scriptNonce is set without ISR, should we set no-store? Looking at existing HTML path for renderPagesPageResponse - scriptNonce always gets no-store regardless of gss...
- Assistant
Running existing unit tests for the affected modules to verify the fix.
- Assistant
The test timed out — trying vitest more directly.
- Assistant
I'll write a small Node script to unit-test the Cache-Control behavior directly.
- Assistant
I'll put the script in the repo and run it with the local node_modules.
- Assistant
There may be a syntax error in pages-page-response.ts — checking the end of the file.
- Assistant
Removing duplicate trailing lines left by a bad edit.
- Assistant
Need to delete lines 431-442.
- Assistant
Re-running the test script after fixing the syntax error.
- Assistant
Building the package, then re-running the targeted unit tests.
- Assistant
I need to build the package first.
- Assistant
vp/build is hanging — checking how the test runner is meant to be invoked.
- Assistant
Vitest is being killed — bundling a minimal test with esbuild instead.
- Assistant
Updating dist for the changed modules so we can run a direct test.
- Assistant
Logic checks out. Patching the dist files so they match our source changes.
- Assistant
I'll try a lighter esbuild-based build of just the changed files.
- Assistant
Checking how source packages resolve in tests and retrying with vite-node.
- Assistant
Vitest keeps getting killed — trying a tsx/esbuild loader approach instead.
- Assistant
Looking up the actual shim paths.
- Assistant
I'll manually patch the compiled dist files next so the changes show up at runtime.
- Assistant
Also need to check if I accidentally overwrote cache-control.js with wrong version.
- Assistant
Patching the dist files to match the source changes.
- Assistant
I'll replace the applyGsspHeaders and cache control section and exports.
- Assistant
Continue patching applyGsspHeaders and render function.
- Assistant
Need to goto line 97 first
- Assistant
Let me replace the a whole section from applyGsspHeaders through export.
- Assistant
Patching pages-data-route.js and pages-server-entry.js next.
- Assistant
Replace buildNextDataJsonResponse
- Assistant
Now pages-server-entry.js
- Assistant
Patch both import and data req path.
- Assistant
Patch import and data path
- Assistant
Now replace data req path
- Assistant
Replace the data req block.
- Assistant
Updating the type definitions and running a test against the dist build.
- Assistant
Update the d.ts exports.
- Assistant
Update.d.ts with new functions.
- Assistant
Checking whether dist is tracked and writing a runner that uses the dist build.
- Assistant
dist is gitignored, so only src changes matter. Running a test that imports from dist.
- Assistant
Typo in the test file — fixing it.
- Assistant
All checks passed. Cleaning up temp files and reviewing the final source diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.