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 to understand the codebase and then work on reproducing the issue.
Assistant
Let me explore the packages directory and understand the structure better.
Assistant
Let me explore the vinext package structure.
Assistant
The issue is about gssp (getServerSideProps) responses missing Cache-Control headers. Let me look at the relevant files.
Assistant
Now I can see the key logic. Let me look at how gssp is dispatched and where
renderPagesPageResponseis called.Assistant
Let me look at the prod-server to see how these functions are used in deploy mode.
Assistant
Let me look at the pages-node-compat.ts to understand how the gssp res headers work.
Assistant
Let me look at the existing tests for pages-page-response to understand expected behavior.
Assistant
Let me look at the data route path and how gssp headers are handled there.
Assistant
Let me look at how the response is processed in the request pipeline and prod-server.
Assistant
Let me search for where the streamed HTML response is handled in the prod-server / cloudflare runtime.
Assistant
Let me look at the prod-server.ts around line 2017 and how the headers are merged.
Assistant
Let me look at
mergeWebResponseand how it merges headers. Let me look at the prod-server around line 270-320.Assistant
Let me check if the e2e test for getserversideprops exists in the repo.
Assistant
Let me write a reproduction test to confirm the issue.
Assistant
Let me check how to run tests in this repo. The package.json uses
vp test run. Let me check the vite config and how tests are run.Assistant
I've confirmed the default Cache-Control is missing for gssp HTML pages (test 1 fails), while user-set Cache-Control works for HTML (test 2 passed). Now let me check the data route path, which the issue also mentions ("user setHeader calls are dropped"). Let me look at the entry code for the data route.
Assistant
Let me look at the Next.js reference test for getserversideprops to understand what's expected.
Assistant
Let me search the tests for how gssp Cache-Control is currently tested in the deploy/pages-router tests.
Assistant
Let me look at the app-route-handler-response.ts to see how App Router handles the default Cache-Control.
Assistant
Let me look at how App Router pages handle the dynamic page Cache-Control in app-page-response.ts.
Assistant
Let me look at how the dev server handles gssp Cache-Control, since it may already have the correct behavior.
Assistant
Let me see how the dev server applies the cache-control for gssp. Let me look further down.
Assistant
Let me look further down for the HTML page render in dev to see how the dev server sets the Cache-Control.
Assistant
Let me check the existing data route tests for header handling.
Assistant
Let me look for the Next.js reference test for getserversideprops.
Assistant
The reference test isn't available. Let me check the installed
nextpackage for the test.Assistant
Let me look at how the existing pages-router tests check gssp behavior and cache-control.
Assistant
Let me look at the prod-server data route test (line 3731) and the ssr-headers fixture.
Assistant
Let me look at the pages-basic fixture to understand the gssp pages.
Assistant
Let me check the installed next package for the getserversideprops e2e test.
Assistant
The next package doesn't include e2e tests. Let me verify the Next.js default Cache-Control behavior by checking its server source.
Assistant
Let me look at the Next.js base-server.js around lines 1259 and 1657 to understand the default Cache-Control application.
Assistant
Let me look at where the gssp default cache-control is set in the Next.js render flow.
Assistant
Let me look at the Next.js render.tsx for the gssp cacheControl value.
Assistant
Let me look at the Next.js cache-control.js to confirm the default for revalidate=0.
Assistant
Let me look at how Next.js
sendRenderResulthandles user-set Cache-Control for gssp.Assistant
sendRenderResultis in a parent class. Let me look at the next-server.js or base-server.js forsendRenderResult. Let me grep more broadly.Assistant
Now I understand the Next.js behavior fully. Let me look at the entry's import setup to add the
NEVER_CACHE_CONTROLimport.Assistant
Let me look at the top section to add the cache-control path import.
Assistant
Let me look at the dev server HTML render response where extraHeaders is applied.
Assistant
Now I have a clear picture. Let me implement the fix. First, the prod HTML path in
pages-page-response.ts.Assistant
Now let me update the cache-control logic in
renderPagesPageResponse.Assistant
Let me use the
editcommand instead.Assistant
Now let me fix the data route path. Let me look at the full
pages-data-route.tsto add a helper that handles gssp headers and the default Cache-Control.Assistant
Now let me add a helper function for the data route that handles gssp headers and the default Cache-Control. First, add the imports.
Assistant
The edit introduced some duplicate lines. Let me view and clean up.
Assistant
Let me remove the duplicate lines.
Assistant
No python. Let me use node to clean up.
Assistant
Now let me add the new helper function after
buildNextDataJsonResponse.Assistant
Now let me update the entry to use the new helper. First the import, then the data route code.
Assistant
Let me open the entry file and use the edit command.
Assistant
Now let me update the data route code to use the new helper.
Assistant
Let me remove the now-unused
__buildNextDataJsonResponsealias from the entry import to keep the generated bundle clean.Assistant
The replace tool requires the file to be currently open. It is open. But it says "Text not found in displayed lines" — probably because the displayed window doesn't contain line 242. Let me use the edit command instead, opening line 242.
Actually wait, I realize
buildNextDataJsonResponseis still exported and used by tests, so keeping the import alias in the entry is harmless. But to be clean, let me just remove it. Let me useediton line 242.Actually, let me reconsider. Is
__buildNextDataJsonResponseused anywhere else in the entry? Let me grep.Assistant
Now let me run the existing tests to make sure my changes don't break anything, then run my repro.
Assistant
All 6 repro tests pass. Now let me run the existing affected tests to ensure no regression.
Assistant
All existing tests pass. Let me check the dev server's data route path too, since the issue mentions "deploy mode" but let me verify the dev path is consistent. First, let me run a typecheck on the affected files.
Assistant
My new comments inside the template string contain unescaped backticks, which break the template literal. Let me fix them.
Assistant
Let me use the edit command to replace the comment lines with escaped backticks.
Assistant
Now let me re-run the typecheck.
Assistant
Typecheck passes. Now let me verify how the Node prod server renders pages — whether it uses the generated
pages-server-entry.tsor its own logic.Assistant
Let me check the test project configuration to understand which tests run.
Assistant
Let me run the integration
pages-router.test.tsto verify end-to-end behavior (this builds fixtures and runs prod server).Assistant
All 241 integration tests pass. Let me write a temporary end-to-end test to confirm the actual deployed server returns the correct Cache-Control headers, then remove it.
Assistant
Let me look at the helpers and how the prod server is started in the test.
Assistant
Let me look at the prod server setup in the test to replicate it.
Assistant
Let me look at the build helper and manifest path setup to write a focused temp e2e test.
Assistant
Let me look at the
startProdServerusage to replicate the prod server setup in my temp test.Assistant
Let me find where
outDiris set up for the prod build in the test.Assistant
Let me check the pages-basic fixture config and write a temp e2e test, including a temp page that overrides Cache-Control.
Assistant
Let me check
startProdServerreturn shape andunwrapStartedProdServer.Assistant
Let me update my temp test to use
unwrapStartedProdServer-style extraction.Assistant
The integration project has an explicit include list. Let me temporarily add my temp test to it, run, then revert.
Assistant
All 6 e2e tests pass against the actual deployed prod server. Now let me clean up the temp files and revert the vite.config.ts changes.
Assistant
Clean. Let me run a few more related unit tests to ensure no regressions, then run the broader pages-related integration tests.
Assistant
Let me check the
entry-templates.test.tswhich may snapshot the generated entry code, since I changed the entry template.Assistant
Let me check the deploy test for any cache-control assertions that might be affected.
Assistant
Let me look at line 877 context to understand what that test does.
Assistant
Let me run the deploy test to be thorough, since the issue is about the deploy suite.
Assistant
deploy.test.tsruns in the unit project. Let me run it there.Assistant
All deploy tests pass. Let me review the final diff of all my changes.
Assistant
The diff is clean and focused. Let me verify there isn't a separate Cloudflare entry that duplicates the data route logic.
Assistant
Let me check the prerender test for any gssp cache-control assertions and run it to be safe.
Assistant
All tests pass. Let me do a final review of the complete modified files to ensure correctness.
Assistant
Let me verify
buildNextDataJsonResponseis still used somewhere (tests) so knip won't flag it.Assistant
Let me run knip to verify no unused-code issues arise from my changes.
Assistant
Knip flags
buildPagesServerDataResponseas unused because its usage is inside the generated template string (not statically visible). Let me check the knip config to see how similar functions are handled.Assistant
I need to handle the knip warning. The repo's convention is to list files whose exports are consumed by generated virtual entries. Let me check the package.json exports and how
pages-data-route.tsrelates.Assistant
The repo's convention is to list files consumed by generated virtual entries in the knip
entrylist. Let me addpages-data-route.tsthere, sincebuildPagesServerDataResponseis consumed via the template-string import in the generated entry.Assistant
Let me add
pages-data-route.tsto the knip entry list, consistent with the existing pattern for files consumed by generated virtual entries.Assistant
knip passes. Let me run the typecheck and lint on the affected files.
Assistant
These errors are pre-existing in
apps/web/(missing cloudflare deps) and unrelated to my changes. Let me confirm the vinext package typecheck is clean after all edits.Assistant
The vinext package typecheck is clean. Let me run the linter on the affected files.
Assistant
Lint passes. Let me run the format check to ensure my changes conform.
Assistant
Format check passes. Let me do a final verification run of the key affected test suites to confirm the final state is green.
Assistant
All green. Let me do a final review of the complete diff and confirm no temp files remain.
Assistant
Let me view the complete final diff one more time to confirm everything is correct.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.