Unverified Commit 8dc0b1be authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix app cache enabling case (#52278)

Ensures we don't attempt using the wrong cache handler during build. 

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1688549526316949)
parent 5046ee13
...@@ -19,6 +19,14 @@ export default class FetchCache implements CacheHandler { ...@@ -19,6 +19,14 @@ export default class FetchCache implements CacheHandler {
private debug: boolean private debug: boolean
private revalidatedTags: string[] private revalidatedTags: string[]
static isAvailable(ctx: {
_requestHeaders: CacheHandlerContext['_requestHeaders']
}) {
return !!(
ctx._requestHeaders['x-vercel-sc-host'] || process.env.SUSPENSE_CACHE_URL
)
}
constructor(ctx: CacheHandlerContext) { constructor(ctx: CacheHandlerContext) {
this.debug = !!process.env.NEXT_PRIVATE_DEBUG_CACHE this.debug = !!process.env.NEXT_PRIVATE_DEBUG_CACHE
this.headers = {} this.headers = {}
......
...@@ -114,7 +114,11 @@ export class IncrementalCache { ...@@ -114,7 +114,11 @@ export class IncrementalCache {
} }
CurCacheHandler = FileSystemCache CurCacheHandler = FileSystemCache
} }
if (minimalMode && fetchCache) { if (
FetchCache.isAvailable({ _requestHeaders: requestHeaders }) &&
minimalMode &&
fetchCache
) {
if (debug) { if (debug) {
console.log('using fetch cache handler') console.log('using fetch cache handler')
} }
......
...@@ -98,6 +98,10 @@ describe('should set-up next', () => { ...@@ -98,6 +98,10 @@ describe('should set-up next', () => {
if (server) await killApp(server) if (server) await killApp(server)
}) })
it('should not fail caching', async () => {
expect(next.cliOutput).not.toContain('ERR_INVALID_URL')
})
it('should send cache tags in minimal mode for ISR', async () => { it('should send cache tags in minimal mode for ISR', async () => {
for (const [path, tags] of [ for (const [path, tags] of [
['/isr/first', 'isr-page,/isr/[slug]/page'], ['/isr/first', 'isr-page,/isr/[slug]/page'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment