Skip to content

Commit 89ff228

Browse files
committed
tmp: just checking if canary tests will be happier
1 parent d41873b commit 89ff228

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/build/content/prerendered.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const writeCacheEntry = async (
4646
const routeToFilePath = (path: string) => (path === '/' ? '/index' : path)
4747

4848
const buildPagesCacheValue = async (path: string): Promise<NetlifyCachedPageValue> => ({
49-
kind: 'PAGE',
49+
kind: 'PAGES',
5050
html: await readFile(`${path}.html`, 'utf-8'),
5151
pageData: JSON.parse(await readFile(`${path}.json`, 'utf-8')),
5252
headers: undefined,
@@ -97,7 +97,7 @@ const buildRouteCacheValue = async (
9797
path: string,
9898
initialRevalidateSeconds: number | false,
9999
): Promise<NetlifyCachedRouteValue> => ({
100-
kind: 'ROUTE',
100+
kind: 'APP_ROUTE',
101101
body: await readFile(`${path}.body`, 'base64'),
102102
...JSON.parse(await readFile(`${path}.meta`, 'utf-8')),
103103
revalidate: initialRevalidateSeconds,
@@ -171,7 +171,7 @@ export const copyPrerenderedContent = async (ctx: PluginContext): Promise<void>
171171
}
172172

173173
// Netlify Forms are not support and require a workaround
174-
if (value.kind === 'PAGE' || value.kind === 'APP_PAGE') {
174+
if (value.kind === 'PAGE' || value.kind === 'PAGES' || value.kind === 'APP_PAGE') {
175175
verifyNetlifyForms(ctx, value.html)
176176
}
177177

src/run/handlers/cache.cts

+18-8
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,18 @@ export class NetlifyCacheHandler implements CacheHandler {
132132

133133
if (
134134
cacheValue.kind === 'PAGE' ||
135+
cacheValue.kind === 'PAGES' ||
135136
cacheValue.kind === 'APP_PAGE' ||
136-
cacheValue.kind === 'ROUTE'
137+
cacheValue.kind === 'ROUTE' ||
138+
cacheValue.kind === 'APP_ROUTE'
137139
) {
138140
if (cacheValue.headers?.[NEXT_CACHE_TAGS_HEADER]) {
139141
const cacheTags = (cacheValue.headers[NEXT_CACHE_TAGS_HEADER] as string).split(',')
140142
requestContext.responseCacheTags = cacheTags
141-
} else if (cacheValue.kind === 'PAGE' && typeof cacheValue.pageData === 'object') {
143+
} else if (
144+
(cacheValue.kind === 'PAGE' || cacheValue.kind === 'PAGES') &&
145+
typeof cacheValue.pageData === 'object'
146+
) {
142147
// pages router doesn't have cache tags headers in PAGE cache value
143148
// so we need to generate appropriate cache tags for it
144149
const cacheTags = [`_N_T_${key === '/index' ? '/' : key}`]
@@ -186,6 +191,7 @@ export class NetlifyCacheHandler implements CacheHandler {
186191
}
187192

188193
async get(...args: Parameters<CacheHandler['get']>): ReturnType<CacheHandler['get']> {
194+
debugger
189195
return this.tracer.withActiveSpan('get cache key', async (span) => {
190196
const [key, ctx = {}] = args
191197
getLogger().debug(`[NetlifyCacheHandler.get]: ${key}`)
@@ -224,8 +230,9 @@ export class NetlifyCacheHandler implements CacheHandler {
224230
value: blob.value,
225231
}
226232

227-
case 'ROUTE': {
228-
span.addEvent('ROUTE', { lastModified: blob.lastModified, status: blob.value.status })
233+
case 'ROUTE':
234+
case 'APP_ROUTE': {
235+
span.addEvent('APP_ROUTE', { lastModified: blob.lastModified, status: blob.value.status })
229236

230237
const valueWithoutRevalidate = this.captureRouteRevalidateAndRemoveFromObject(blob.value)
231238

@@ -237,7 +244,8 @@ export class NetlifyCacheHandler implements CacheHandler {
237244
},
238245
}
239246
}
240-
case 'PAGE': {
247+
case 'PAGE':
248+
case 'PAGES': {
241249
span.addEvent('PAGE', { lastModified: blob.lastModified })
242250

243251
const { revalidate, ...restOfPageValue } = blob.value
@@ -275,15 +283,15 @@ export class NetlifyCacheHandler implements CacheHandler {
275283
data: Parameters<IncrementalCache['set']>[1],
276284
context: Parameters<IncrementalCache['set']>[2],
277285
): NetlifyIncrementalCacheValue | null {
278-
if (data?.kind === 'ROUTE') {
286+
if (data?.kind === 'ROUTE' || data?.kind === 'APP_ROUTE') {
279287
return {
280288
...data,
281289
revalidate: context.revalidate,
282290
body: data.body.toString('base64'),
283291
}
284292
}
285293

286-
if (data?.kind === 'PAGE') {
294+
if (data?.kind === 'PAGE' || data?.kind === 'PAGES') {
287295
return {
288296
...data,
289297
revalidate: context.revalidate,
@@ -397,8 +405,10 @@ export class NetlifyCacheHandler implements CacheHandler {
397405
cacheTags = [...tags, ...softTags]
398406
} else if (
399407
cacheEntry.value?.kind === 'PAGE' ||
408+
cacheEntry.value?.kind === 'PAGES' ||
400409
cacheEntry.value?.kind === 'APP_PAGE' ||
401-
cacheEntry.value?.kind === 'ROUTE'
410+
cacheEntry.value?.kind === 'ROUTE' ||
411+
cacheEntry.value?.kind === 'APP_ROUTE'
402412
) {
403413
cacheTags = (cacheEntry.value.headers?.[NEXT_CACHE_TAGS_HEADER] as string)?.split(',') || []
404414
} else {

src/shared/cache-types.cts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type NetlifyCachedAppPageValue = Omit<IncrementalCachedAppPageValue, 'rsc
2828
revalidate?: Parameters<IncrementalCache['set']>[2]['revalidate']
2929
}
3030

31-
type CachedPageValue = Extract<IncrementalCacheValue, { kind: 'PAGE' }>
31+
type CachedPageValue = Extract<IncrementalCacheValue, { kind: 'PAGES' }>
3232

3333
export type NetlifyCachedPageValue = CachedPageValue & {
3434
revalidate?: Parameters<IncrementalCache['set']>[2]['revalidate']

0 commit comments

Comments
 (0)