Repository: vercel/next.js
Pull request: tests: disable flaky deployment test while investigating upstream

This test has started failing when deployed to hosted environments, but it consistently is passing in `next start` tests. 

We could retry the on-demand revalidation and the test will pass, but we lose the value in the test.

This instead temporarily disables it until it can be investigated upstream. 

[slack x-ref](https://vercel.slack.com/archives/C04KC8A53T7/p1757108995256419)

Changed files:
filename: test/e2e/prerender.test.ts
patch: @@ -2294,7 +2294,11 @@ describe('Prerender', () => {
       })
     }
 
-    if (!isDev) {
+    // This test is disabled in deployed environments because the initial on-demand revalidate call
+    // is not actually producing a new response, until it's called for a second time
+    // Rather than retrying just to fix the test, we need to investigate what might
+    // be causing this behavior in a deployed environment.
+    if (!isDev && !isDeploy) {
       it('should handle on-demand revalidate for fallback: blocking', async () => {
         const res = await fetchViaHTTP(
           next.url,
@@ -2309,21 +2313,19 @@ describe('Prerender', () => {
         expect(res.headers.get(cacheHeader)).toMatch(/MISS/)
         expect($('p').text()).toMatch(/Post:.*?test-manual-1/)
 
-        if (!isDeploy) {
-          // we use retry here as the cache might still be
-          // writing to disk even after the above request has finished
-          await retry(async () => {
-            const res2 = await fetchViaHTTP(
-              next.url,
-              '/blocking-fallback/test-manual-1'
-            )
-            const html2 = await res2.text()
-            const $2 = cheerio.load(html2)
+        // we use retry here as the cache might still be
+        // writing to disk even after the above request has finished
+        await retry(async () => {
+          const res2 = await fetchViaHTTP(
+            next.url,
+            '/blocking-fallback/test-manual-1'
+          )
+          const html2 = await res2.text()
+          const $2 = cheerio.load(html2)
 
-            expect(res2.headers.get(cacheHeader)).toMatch(/(HIT|STALE)/)
-            expect(initialTime).toBe($2('#time').text())
-          })
-        }
+          expect(res2.headers.get(cacheHeader)).toMatch(/(HIT|STALE)/)
+          expect(initialTime).toBe($2('#time').text())
+        })
 
         const res3 = await fetchViaHTTP(
           next.url,
@@ -2345,6 +2347,7 @@ describe('Prerender', () => {
           )
           const html4 = await res4.text()
           const $4 = cheerio.load(html4)
+
           expect($4('#time').text()).not.toBe(initialTime)
           expect(res4.headers.get(cacheHeader)).toMatch(/(HIT|STALE)/)
         })

filename: test/e2e/prerender/pages/api/manual-revalidate.js
patch: @@ -3,6 +3,7 @@ export default async function handler(req, res) {
   // make sure to use trusted value for revalidating
   let revalidated = false
   try {
+    console.log('API: Called res.revalidate for ', req.query.pathname)
     await res.revalidate(req.query.pathname, {
       unstable_onlyGenerated: !!req.query.onlyGenerated,
     })

filename: test/e2e/prerender/pages/blocking-fallback/[slug].js
patch: @@ -41,16 +41,22 @@ export async function getStaticProps({ params }) {
 
   console.log(`getStaticProps ${params.slug}`)
 
-  return {
+  const result = {
     props: {
       params,
       hello: 'world',
       post: params.slug,
       random: Math.random(),
       time: (await import('perf_hooks')).performance.now(),
     },
-    revalidate: 1,
   }
+
+  // Don't add revalidate for test-manual-1 to test pure on-demand revalidation
+  if (params.slug !== 'test-manual-1') {
+    result.revalidate = 1
+  }
+
+  return result
 }
 
 export default ({ post, time, params }) => {