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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
Now let me look at the existing tests structure and existing tests for gssp:
Assistant
Now let me search for
gssporgetServerSidePropsreferences:Assistant
Now let me look at how
createGsspReqResworks:Assistant
let me look at the test mentioned in the issue. Let me look at the next.js test that's failing:
Assistant
Let me check the next.js original test file:
Assistant
The default Next.js gssp cache control header is
private, no-cache, no-store, max-age=0, must-revalidate. Let me look at the next.js source to understand where this is setAssistant
Let me look at the next.js pages-handler to understand how it sets the cache-control for gs
Assistant
Now let me look at the existing cache-control and cache-headers in vinext:
Assistant
NEVER_CACHE_CONTROLis already defined. Now let me look at the pages-page-response.ts again to find where the cache-control needs to be set for gssp responses:Assistant
me look at the next.js test file to understand what tests are failing:
Assistant
Let me look at the cloudflare-pages-router fixture and SSR tests:
Assistant
Now I understand the context. Let me reproduce the issue first to confirm. Let me look at the page-router test setup:
Assistant
Let me look at the deploy mode to understand the full picture:
Assistant
Let me write a reproduction script:
Assistant
Now let me write a reproduction script to verify the current behavior:
Assistant
Let me run the existing test first to see how it currently behaves:
Assistant
Now let me create a reproduction test to verify the issue:
Assistant
Let me also add the test fixture for the user-set Cache-Control case:
Assistant
Now let me run the test to see the actual behavior:
Assistant
Good. Now let me run my reproduction:
Assistant
Let me write the reproduction test inline within an existing test file to validate the behavior:
Assistant
Let me write the test as a proper test in a test file to actually validate the behavior:
Assistant
The integration project only runs files that are explicitly included. Let me look at the structure:
Assistant
Let me add my tests to the existing pages-router.test.ts to verify behavior. Actually, the instructions say not to modify existing tests, but adding temporary tests should be ok as long as I remove them before submitting. Let me put the test in the existing test file for now (and remove after):
Assistant
Now I need to add it to the include list:
Assistant
I've confirmed the issue - default
Cache-Controlis missing in dev mode. Now let me check the prod/deploy mode too:Assistant
Let me check the worker entry for deploy mode:
Assistant
Now let me focus on making the fix. Let me look at the relevant code:
Assistant
Now let me check the imports and the existing helpers to confirm I can use
NEVER_CACHE_CONTROL:Assistant
Now let me apply the fix:
Assistant
Now let me make the fix:
Assistant
Now let me apply the actual fix to add the default Cache-Control for gssp responses:
Assistant
Now let me run my reproduction test to verify the fix:
Assistant
test still fails. Let me check if the fix is correctly applied:
Assistant
The fix is applied. Let me see if there are any caching issues:
Assistant
Let me check the dev mode code path to see if gsspRes is set:
Assistant
Let me add some debugging to see why the gsspRes is null in dev mode:
Assistant
debug line didn't appear, which means the code change isn't being picked up. Let me check:
Assistant
OK so the source is correctly modified, but the test isn't picking up the changes. Let me check the dist file
Assistant
dist file doesn't have my changes. Let me check how the dev server is loading it:
Assistant
The package main is
dist/index.js. The dev server uses the built dist. Let me check the source loading in dev mode:Assistant
Wait, the function
resolveRuntimeEntryModuleis used. Let me check what's used in pages-server-entry.ts:Assistant
Let me check how Vite handles the path resolution and which version of the file is loaded:
Assistant
me look at the dist of pages-page-response.js to see if there's caching issue:
Assistant
already added a console.log to the source. Let me run the test again and look more carefully:
Assistant
Let me check what's actually being used by the dev server. Let me look at the runtime entry module logic:
Assistant
Let me check the actual path used in the generated server entry. Let me make a quick test that creates a server and checks the response:
Assistant
Wait! The path is
/vinext/server/pages-page-response.jsnot/vinext/packages/vinext/src/server/pages-page-response.js. Theimport.meta.urlis being resolved as if the module is at the root level.Assistant
The test loads from the
distdirectory! Let me find the build command:Assistant
Now the build is updated. Let me run the test again:
Assistant
The DEBUG log isn't showing. Let me check how the dev server actually uses the modules:
Assistant
me look at how the dev server handles pages:
Assistant
dev server uses its own implementation of
streamPageToResponse. Let me look at how it handles gssp responses:Assistant
see! In dev mode, the cache-control is set ONLY if
isrRevalidateSecondsis true. I need to add the default Cache-Control for gssp pages in dev mode too:Assistant
me also look at where this is set in dev-server.ts:
Assistant
Now let me check if
NEVER_CACHE_CONTROLis imported in dev-server.ts:Assistant
Now let me run the test again to see if it works in dev mode:
Assistant
The key is lowercased. Let me fix this:
Assistant
Both tests pass now. Let me also remove the debug log and run all existing tests to make sure I didn't break anything:
Assistant
Now let me check the changes I made:
Assistant
Now let me rebuild and run the existing pages-router tests to make sure I didn't break anything:
Assistant
All 241 pages-router tests pass! Now let me also run other related tests to ensure I haven't broken anything:
Assistant
Let me also check the deploy tests:
Assistant
Let me check if there are any temporary test files I added that need to be cleaned up:
Assistant
Now let me clean up the temporary files I added and revert the vite.config.ts change:
Assistant
Now let me look at the actual fix diff and double-check:
Assistant
Now let me look at the deploy mode (Cloudflare Workers). The deploy tests might also be affected. Let me check the cloudflare-workers tests for pages router:
Assistant
me check how the prod server uses
renderPagesPageResponse:Assistant
Let me also look at the
_next/dataJSON endpoint path to ensure consistency:Assistant
Let me check the gsspRes.headers structure:
Assistant
data request code uses
gsspRes.headerswhich doesn't exist on the type - it should usegsspRes.getHeaders(). Let me check this:Assistant
Let me check if the data request path needs fixing too:
Assistant
Let me also fix the data request path that incorrectly uses
gsspRes.headersinstead ofgsspRes.getHeaders():Assistant
Assistant
All 241 tests pass. Let me also run the broader test suite to ensure I haven't broken anything:
Assistant
Now let me also write a reproduction script to verify the fix is correct, especially for the deploy/prod mode. First let me re-add my test file and the fixture:
Assistant
Both tests pass. Let me also check the data request path by adding a test for that:
Assistant
Let me update my test to verify the data request path:
Assistant
Let me check the dev mode data request path:
Assistant
me also fix the dev mode data request handler:
Assistant
Let me check why the user-set Cache-Control isn't forwarded in data requests:
Assistant
Let me debug by printing the actual headers:
Assistant
I have a bug -
hasGsspis referenced before initialization. Let me look at the code:Assistant
I need to move the
hasGsspdeclaration before the data request handler. Let me restructure:Assistant
The issue is that
gsspExtraHeadersis empty when user doesn't set any headers. I need to track separately if gssp was used:Assistant
All 4 tests pass. Now let me also make sure the existing tests still pass:
Assistant
All 241 tests pass. Let me also run the other tests:
Assistant
All 404 tests pass! Let me now check the changes I made:
Assistant
Now let me clean up my test files and verify everything works:
Assistant
Now let me think about edge cases:
-
What if user has set
scriptNonceAND user-set Cache-Control? My fix sets default Cache-Control, then scriptNonce overrides it. That's correct. -
What if user has set ISR AND user-set Cache-Control? ISR overrides Cache-Control. That's correct because ISR pages are static.
-
What about gssp returning
notFound: true? Let me check:
-
Assistant
me check the other code paths (redirect, json, send) in the dev mode:
Assistant
Let me check the scriptNonce case in dev mode:
Assistant
Let me run the broader test suite to confirm nothing is broken:
Assistant
All 640 tests pass. Let me also check the unit tests:
Assistant
All 4755 unit tests pass! Now let me also confirm my final changes are clean:
Assistant
Let me also check that I haven't accidentally added any debug code:
Assistant
No debug code. Let me look at the final diff one more time:
Assistant
Let me also use the
NEVER_CACHE_CONTROLconstant inpages-server-entry.tsfor consistency:Assistant
The pages-server-entry.ts is a generated file. Let me check if it's actually generated or hand
Assistant
me check if I can use the existing constant in the generated entry:
Assistant
Let me check the prod mode tests to verify the fix works there too:
Assistant
Let me run a few more relevant tests to make sure everything works:
Assistant
All getServerSideProps-related tests pass. Let me also verify the existing tests for
cache-controlstill pass:Assistant
are CSP-related test failures in production mode. Let me investigate:
Assistant
Let me check if these tests were failing before my changes:
Assistant
These tests were failing before my changes too. They're pre-existing failures unrelated to my fix. Let me restore my changes:
Assistant
Let me run all ISR-related tests to ensure my fix doesn't break ISR:
Assistant
Let me run the specific test that checks ISR + CSP nonce:
Assistant
Dev mode ISR + CSP test passes. Now let me check the prod-mode ISR test which was failing:
Assistant
Let me write a quick test for the prod mode to verify my fix:
Assistant
All 3 tests pass for the prod mode! Let me also verify it works in the deploy mode by looking at the prod mode tests:
Assistant
, the test expectation was wrong. The
ssr-headerspage only setsx-custom-header, notCache-Control. So with my fix, the defaultNEVER_CACHE_CONTROLis set. This is the correct behavior! Let me update the test:Assistant
All 3 prod mode tests pass. Now let me also create a test for user-set Cache-Control in prod mode by adding a new fixture file:
Assistant
All 5 prod mode tests pass:
- ✅ Default gssp Cache-Control is applied (HTML)
- ✅ User-set Cache-Control overrides the default (HTML)
- ✅ Custom user-set headers are preserved alongside default Cache-Control (HTML)
- ✅ Default gssp Cache-Control is applied (data request)
- ✅ User-set Cache-Control overrides the default (data request)
Let me now clean up my temporary test files:
Assistant
Now let me do one final check to make sure everything is in order:
Assistant
All 640 tests pass! Let me also do one final review of my changes:
Assistant
me also check the dist files to ensure they match:
Assistant
All the dist files match the source. Now let me also run my reproduction test one more time to confirm everything works:
Assistant
All 4 dev mode tests pass. Let me also clean up and check the final state:
Assistant
Let me do a final comprehensive verification by running all relevant tests:
Assistant
All 584 tests pass. Let me also do one last check to ensure the changes are minimal and correct:
Assistant
Assistant
The changes are clean - only the 3 source files are modified, no temporary test files or fixtures left behind.
Assistant
Ready to submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.