Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Pages Router: gssp/getStaticProps responses missing default and…

  1. User

    ISSUE DESCRIPTION

    Pages Router: gssp/getStaticProps responses missing default and user-set Cache-Control header

    This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-22).

    Problem

    Pages Router gssp responses lack Cache-Control headers. Tests expect the default private, no-cache, no-store, max-age=0, must-revalidate for gssp pages and custom values set via res.setHeader('Cache-Control', ...), but vinext returns null. The default header is not applied and user setHeader calls are dropped.

    Expected: "private, no-cache, no-store, max-age=0, must-revalidate"
    Received: null
    

    Estimated Impact

    ~2 test failures across the deploy suite.

    Affected Test Suites

    • test/e2e/getserversideprops/test/index.test.ts (2 failures)

    Recommendation

    1. Reproduce first in vinext's own test suite. Add a Pages Router gssp page and assert the response carries the default Cache-Control header; add a second page that overrides it via res.setHeader and assert the override sticks.

    2. 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-revalidate unless the user set it explicitly.

    3. Preserve res.setHeader overrides. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /vinext, current file: none) bash-$

  2. Assistant

    I'll start by exploring the repository structure to understand the codebase and locate relevant files. Let's first get an overview.

  3. Assistant

    Let me look at the repository structure more carefully. It seems to be a monorepo with packages.

  4. Assistant

    Let me explore the test file mentioned in the issue to understand what's expected.

  5. Assistant

    The test file mentioned in the issue doesn't seem to exist in this repository directly. Let me search more broadly.

  6. Assistant

    Let me search more broadly for test files related to gssp or cache-control.

  7. Assistant

    Let me look at the source files, not just dist files.

  8. Assistant

    Let me search for the relevant source files related to pages router and getServerSideProps.

  9. Assistant

    Let me look at the pages-page-response.ts and pages-page-data.ts files, as these are likely where the Cache-Control headers should be set for getServerSideProps responses.

  10. Assistant

    Let me look at the pages-page-data.ts and headers.ts to understand how Cache-Control is handled.

  11. Assistant

    Let me look at the cache-control.ts file to understand the default cache control logic, and the prod-server.ts to see how the response is assembled.

  12. Assistant

    Now let me look at the prod-server.ts to see how pages responses are handled.

  13. Assistant

    Let me look at the test file to understand what's expected.

  14. Assistant

    Let me look at the test files to understand what's expected for GSSP Cache-Control headers.

  15. Assistant

    Let me look at the pages router test file to find Cache-Control assertions.

  16. Assistant

    Let me search more broadly.

  17. Assistant

    Let me search for the specific test mentioned in the issue.

  18. Assistant

    Let me look at the pages-page-response test file to understand the testing structure.

  19. Assistant

    Let me understand the flow better. Let me look at the existing test for gssp headers and the deploy test file.

  20. Assistant

    Let me look at how createGsspReqRes works to understand the response object passed to getServerSideProps:

  21. Assistant

    Let me check how gssp req/res is created in the pages-server-entry.ts:

  22. Assistant

    Let me find the __createPagesReqRes function:

  23. Assistant

    Let me look for the pages-node-compat file:

  24. Assistant

    Let me examine the pages-node-compat.ts file:

  25. Assistant

    Now I understand the issue. Let me trace the code flow. The problem is in pages-page-response.ts. Let me look at the relevant section:

  26. Assistant

    Let me look at the relevant code around the Cache-Control logic to understand the issue better.

  27. Assistant

    Now I understand the issue. Let me verify my understanding by checking how the import works and what the fix should be:

  28. Assistant

    Now I understand the issue. Looking at the code in renderPagesPageResponse, I can see that:

    1. applyGsspHeaders() applies headers set by the user via res.setHeader() during getServerSideProps
    2. Cache-Control is only set when scriptNonce or isrRevalidateSeconds are present
    3. For gssp pages (getServerSideProps), isrRevalidateSeconds is null, so no default Cache-Control is set

    The fix is to set a default Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate for gssp pages when no Cache-Control is already set. Let me also look at how the test expects this:

  29. Assistant

    Let me look at the test files related to gssp to understand what they expect. Let me check the deploy test and the pages router test:

  30. Assistant

    Now I understand the issue. Let me trace the code:

    1. In renderPagesPageResponse, applyGsspHeaders applies user-set headers from gsspRes (which includes res.setHeader calls during getServerSideProps)
    2. Cache-Control is only set in two cases: scriptNonce → no-store, must-revalidate, or isrRevalidateSeconds → ISR cache control
    3. For gssp pages, isrRevalidateSeconds is null, so no default Cache-Control header is set

    The fix needs to:

    1. Set a default Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate for gssp pages when no Cache-Control was already set
    2. Preserve user-set Cache-Control headers from res.setHeader

    Let me also check what NEVER_CACHE_CONTROL constant looks like:

  31. Assistant

    Now I understand the issue completely. Let me implement the fix.

    The problem is in pages-page-response.ts. When rendering a gssp page (getServerSideProps), there's no default Cache-Control header set. In Next.js, gssp pages should have Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate by default, and user-set headers via res.setHeader('Cache-Control', ...) should be preserved.

    The fix needs to:

    1. Import NEVER_CACHE_CONTROL from ./cache-control.js
    2. Add a condition after the existing Cache-Control logic to set the default for gssp pages when no Cache-Control was already set
  32. Assistant

    Let me look at the exact code to modify in pages-page-response.ts:

  33. Assistant

    Now I understand the issue. Let me look at how the existing test handles the gssp case without Cache-Control:

  34. Assistant

    Let me check the pages-page-data test to see if there are tests related to gssp Cache-Control:

  35. Assistant

    Let me look at the test cases around those lines to understand the context better.

  36. Assistant

    Now I understand the issue. Let me trace through the code:

    1. In pages-page-response.ts, the renderPagesPageResponse function creates response headers
    2. It applies gssp headers via applyGsspHeaders() which includes user-set headers from res.setHeader()
    3. Cache-Control is only set in two cases:
      • scriptNonce → no-store, must-revalidate
      • isrRevalidateSeconds → ISR cache control

    The problem is that for gssp pages (getServerSideProps), isrRevalidateSeconds is null, so no default Cache-Control is set. In Next.js, gssp pages should get Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate unless the user explicitly sets it via res.setHeader.

    However, gsspRes is set for both getServerSideProps and getStaticProps pages. We need to distinguish between the two to know when to apply the default.

    Let me look at how the test expects this behavior:

  37. Assistant

    Let me look at the pages-server-entry.ts to understand how the response is assembled:

  38. Assistant

    Let me search for where renderPagesPageResponse is called with gsspRes:

  39. Assistant

    Let me look at lines 710-780 to understand how the gsspRes is used.

  40. Assistant

    Now I understand the issue completely. Let me look at how buildNextDataJsonResponse works to understand the data request path:

  41. Assistant

    Now I understand the issue completely. Let me trace through the code:

    1. In pages-page-response.ts, renderPagesPageResponse creates response headers
    2. applyGsspHeaders copies user-set headers from gsspRes
    3. Cache-Control is only set when scriptNonce or isrRevalidateSeconds are present
    4. For gssp pages (getServerSideProps), isrRevalidateSeconds is null, so NO default Cache-Control is set

    The problem is that gsspRes is set for BOTH getServerSideProps and getStaticProps pages, but we need to distinguish them:

    • getServerSideProps pages: should get default Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate unless user overrides
    • getStaticProps pages: get ISR cache control or no default

    Let me implement the fix. I need to:

    1. Add a gssp flag to ResolvePagesPageDataRenderResult in pages-page-data.ts
    2. Set it to true only in the getServerSideProps path
    3. Use it in renderPagesPageResponse to set the default Cache-Control
    4. Import NEVER_CACHE_CONTROL in pages-page-response.ts
  42. Assistant

    Let me look at how the data request path handles headers:

  43. Assistant

    Now I understand the issue completely. Let me trace through the code:

    1. In pages-page-response.ts, renderPagesPageResponse creates response headers
    2. applyGsspHeaders copies headers from gsspRes (which includes user-set headers via res.setHeader)
    3. Cache-Control is only set when scriptNonce or isrRevalidateSeconds are present
    4. For gssp pages (getServerSideProps), isrRevalidateSeconds is null, so no default Cache-Control is set

    The fix needs to:

    1. Set default Cache-Control for gssp pages when no Cache-Control was already set
    2. Import NEVER_CACHE_CONTROL from cache-control.ts

    Let me first check the existing test to understand what's expected:

  44. Assistant

    Now I understand the issue completely. Let me implement the fix:

    1. In pages-page-response.ts:

      • Import NEVER_CACHE_CONTROL from ./cache-control.js
      • After the existing Cache-Control logic, add a condition for gssp pages when no Cache-Control was already set
    2. The key insight is:

      • gsspRes is set for getServerSideProps pages (where isrRevalidateSeconds is null)
      • For ISR pages (getStaticProps with revalidate), isrRevalidateSeconds is set and Cache-Control is handled
      • The user-set headers via res.setHeader are already copied by applyGsspHeaders

    Let me implement the fix:

  45. Assistant

    Let me implement the fix. I need to:

    1. Import NEVER_CACHE_CONTROL in pages-page-response.ts
    2. Add a condition after the existing Cache-Control logic to set default Cache-Control for gssp pages when no Cache-Control was already set
  46. Assistant

    Now I'll implement the fix. First, update the import:

  47. Assistant

    Let me open the file and use the edit command properly.

  48. Assistant

    Now I can edit the file. Let me update the import first:

  49. Assistant

    Let me use sed to make the changes:

  50. Assistant

    Now let me add the default Cache-Control for gssp pages. First, let me check the current code around line 380:

  51. Assistant

    Now I understand the issue. The problem is in the renderPagesPageResponse function. For GSSP (getServerSideProps) pages:

    1. gsspRes is set (it's the response object from GSSP)
    2. isrRevalidateSeconds is null (GSSP pages don't use ISR)
    3. The code only sets Cache-Control if scriptNonce or isrRevalidateSeconds is set
    4. So GSSP pages get NO default Cache-Control header

    The fix is to add an else case that sets the default NEVER_CACHE_CONTROL for GSSP pages when no ISR or scriptNonce is set. This preserves user-set Cache-Control because:

    • User-set headers from res.setHeader are applied by applyGsspHeaders (line 377)
    • If scriptNonce is set, it overrides with no-store, must-revalidate
    • If isrRevalidateSeconds is set, it overrides with ISR cache control
    • Otherwise (GSSP without scriptNonce), we set the default NEVER_CACHE_CONTROL

    Let me also check how gsspRes is set to understand the distinction:

  52. Assistant

    Now I need to add the default Cache-Control for gssp pages. Let me also check the data request path to make sure it handles Cache-Control too:

  53. Assistant

    Now let me also check the data request path. The data request path (isDataReq) forwards headers from gsspRes but doesn't set a default Cache-Control. Let me add the fix in pages-page-response.ts:

  54. Assistant

    Now let me also check the data request path. Looking at lines 711-725, the data request path also needs the default Cache-Control for gSSP pages:

  55. Assistant

    Now I need to add the default Cache-Control for gssp pages. The fix needs to be in renderPagesPageResponse - after the existing Cache-Control logic, add a condition for gssp pages when no Cache-Control was already set.

    Let me first verify the import was added correctly:

  56. Assistant

    Now I need to add the logic for setting default Cache-Control for gssp pages. Let me also check the data request path in pages-server-entry.ts to see if it needs the same fix:

  57. Assistant

    Let me look at the pages-page-data.ts to understand how the result is returned:

  58. Assistant

    Now I understand the issue. Let me implement the fix. The problem is that in renderPagesPageResponse, Cache-Control is only set when scriptNonce or isrRevalidateSeconds are set. For gssp pages (getServerSideProps), isrRevalidateSeconds is null, so no default Cache-Control is set.

    I need to:

    1. Add default Cache-Control for gssp pages in renderPagesPageResponse
    2. Also handle the data request path in pages-server-entry.ts

    Let me first add the fix to pages-page-response.ts:

  59. Assistant

    Let me try using node instead:

  60. Assistant

    Now let me also fix the data request path in pages-server-entry.ts:

  61. Assistant

    Let me verify the changes I made:

  62. Assistant

    Let me search for the specific section I modified:

  63. Assistant

    Now let me verify the change in pages-server-entry.ts:

  64. Assistant

    Good. Now let me also check the gsspRes.headers handling in pages-node-compat.ts to make sure res.setHeader('Cache-Control', ...) stores lowercase 'cache-control':

  65. Assistant

    Good. I can see that setHeader stores keys in lowercase:

    resHeaders[name.toLowerCase()] = Array.isArray(value) ? value.join(", ") : value;
    

    So the check for "cache-control" will work. Now let me run the existing tests to make sure my changes don't break anything:

  66. Assistant

    Let me try using the available test runner:

  67. Assistant

    Let me check what test runner is used:

  68. Assistant

    Let me run the tests using the project's test runner:

  69. Assistant

    Now let me also run the pages-page-data tests:

  70. Assistant

    Now let me run the pages-router tests:

  71. Assistant

    The integration test failure is likely caused by my TypeScript type annotation in pages-server-entry.ts. The file generates a JavaScript entry module, so I need to remove the type annotation:

  72. Assistant

    Let me look at the original code in pages-server-entry.ts to understand the issue:

  73. Assistant

    I see the issue - this is a TypeScript file that generates JavaScript code as strings. The TypeScript type annotation will be emitted as-is into the generated JS module, causing a syntax error. Let me revert that change and fix it properly:

  74. Assistant

    Let me check the exact context of this file to understand if this is source code or generated code:

  75. Assistant

    Wait, looking at this more carefully, this is a TypeScript source file that generates JavaScript code as strings. Let me check if the area I modified is part of the generated code or TypeScript source code:

  76. Assistant

    Let me check the current state of the data request handling:

  77. Assistant

    Wait, I need to look at this more carefully. The pages-server-entry.ts file generates JavaScript code as a template string. Let me check if the code I modified is part of the template string or TypeScript source:

  78. Assistant

    I see - this is a template literal string starting at line 209. The code at line 710+ is inside this template literal. So the code I modified is generated JavaScript, not TypeScript source. Let me verify the current state is correct (no TypeScript annotations):

  79. Assistant

    Good, the code is inside a template literal. My changes look correct now - I removed the TypeScript annotation and the code should be valid JavaScript. Let me verify the current state:

  80. Assistant

    Let me run the failing test again to see if it passes now:

  81. Assistant

    Now let me also verify the data request path. Let me check the buildNextDataJsonResponse function to see if it properly forwards headers:

  82. Assistant

    Good. The buildNextDataJsonResponse function merges init?.headers into the response headers. Let me now write a quick test to verify the fix works:

  83. Assistant

    Let me just run the existing tests to make sure everything passes:

  84. Assistant

    Now let me also write a temporary test to verify the fix works:

  85. Assistant

    Let me also run the full test suite to make sure nothing is broken:

  86. Assistant

    Let me run the unit tests only:

  87. Assistant

    All unit tests pass. Let me also run the integration tests:

  88. Assistant

    Let me run just the key pages-router integration test:

  89. Assistant

    All tests pass. Let me verify my changes are correct by reviewing the diff:

  90. Assistant

    The changes look good. Let me also check if there are any edge cases I need to consider. Let me verify the behavior of setCacheStateHeaders:

  91. Assistant

    Good. The setCacheStateHeaders function only sets VINEXT_CACHE_HEADER and NEXTJS_CACHE_HEADER (for cache state), not Cache-Control. So that's fine.

    Let me now also verify that the data request path works correctly. Let me look at how buildNextDataJsonResponse handles the headers:

  92. Assistant

    Now let me verify that the header check in pages-server-entry.ts works correctly. The headers from res.setHeader are stored with lowercase keys in pages-node-compat.ts:

  93. Assistant

    Let me check if the setHeader method stores the header with lowercase keys:

  94. Assistant

    The setHeader method stores headers with lowercase keys (name.toLowerCase()). So if the user calls res.setHeader('Cache-Control', 'public, max-age=3600'), it will be stored as cache-control: 'public, max-age=3600' in the headers object.

    In the data request path, I check !init.headers?.["cache-control"], which is correct because the headers are stored with lowercase keys.

    Let me now run the full test suite to make sure everything is working correctly:

  95. Assistant

    All 4755 unit tests pass. Let me verify the final state of my changes:

  96. Assistant

    Let me do a final review of the complete diff:

  97. Assistant

    The changes look correct. Let me now verify one more edge case - when the user explicitly sets Cache-Control via res.setHeader:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.