File size: 4,002 Bytes
b2cad4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
diff --git a/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts b/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts
index 68a7f8f2c6..9c333a663c 100644
--- a/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts
+++ b/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts
@@ -9,6 +9,7 @@ describe('action-only fallback resume data cache', () => {
       : {
           NEXT_PRIVATE_TEST_HEADERS: '1',
           NEXT_PRIVATE_MINIMAL_MODE: '1',
+          TEST_CACHE_HANDLER: '1',
         },
   })
 
@@ -70,6 +71,8 @@ describe('action-only fallback resume data cache', () => {
     }
 
     it('handles postponed state on an action-only fallback request', async () => {
+      const outputIndex = next.cliOutput.length
+
       const response = await invokeAction('readCachedValue')
 
       expect(response.status).toBe(200)
@@ -77,15 +80,25 @@ describe('action-only fallback resume data cache', () => {
       const responseBody = await response.text()
       expect(responseBody).toContain('cached value')
       expect(responseBody).not.toContain('destination page rendered')
+
+      const output = next.cliOutput.slice(outputIndex)
+      expect(output).toContain('ActionOnlyFallbackCacheHandler::updateTags')
+      expect(output).toContain('_N_T_/events/foo/group')
     })
 
-    it('does not render the fallback route when the action calls notFound', async () => {
+    it('applies pending revalidations without rendering the fallback route when the action calls notFound', async () => {
+      const outputIndex = next.cliOutput.length
+
       const response = await invokeAction('notFoundAfterRevalidation')
 
       expect(response.status).toBe(404)
       expect(response.headers.get('content-type')).toContain('text/x-component')
       const responseBody = await response.text()
       expect(responseBody).not.toContain('destination page rendered')
+
+      const output = next.cliOutput.slice(outputIndex)
+      expect(output).toContain('ActionOnlyFallbackCacheHandler::updateTags')
+      expect(output).toContain('_N_T_/events/foo/group')
     })
   }
 })
diff --git a/test/production/app-dir/action-only-fallback-resume-data-cache/cache-handler.js b/test/production/app-dir/action-only-fallback-resume-data-cache/cache-handler.js
new file mode 100644
index 0000000000..84768037bb
--- /dev/null
+++ b/test/production/app-dir/action-only-fallback-resume-data-cache/cache-handler.js
@@ -0,0 +1,23 @@
+// @ts-check
+
+const defaultCacheHandler =
+  require('next/dist/server/lib/cache-handlers/default.external').default
+
+/**
+ * @type {import('next/dist/server/lib/cache-handlers/types').CacheHandler}
+ */
+const cacheHandler = {
+  get: defaultCacheHandler.get.bind(defaultCacheHandler),
+  set: defaultCacheHandler.set.bind(defaultCacheHandler),
+  refreshTags: defaultCacheHandler.refreshTags.bind(defaultCacheHandler),
+  getExpiration: defaultCacheHandler.getExpiration.bind(defaultCacheHandler),
+  async updateTags(tags) {
+    console.log(
+      'ActionOnlyFallbackCacheHandler::updateTags',
+      JSON.stringify(tags)
+    )
+    return defaultCacheHandler.updateTags(tags)
+  },
+}
+
+module.exports = cacheHandler
diff --git a/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js b/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js
index e64bae22d6..337d9c2e1e 100644
--- a/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js
+++ b/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js
@@ -3,6 +3,11 @@
  */
 const nextConfig = {
   cacheComponents: true,
+  cacheHandlers: process.env.TEST_CACHE_HANDLER
+    ? {
+        default: require.resolve('./cache-handler.js'),
+      }
+    : undefined,
 }
 
 module.exports = nextConfig