Unverified Commit c23f9577 authored by Sebastian Markbåge's avatar Sebastian Markbåge Committed by GitHub

Disable "use cache" outside of dynamicIO (#70538)

parent a1840471
...@@ -183,6 +183,7 @@ export function getDefineEnv({ ...@@ -183,6 +183,7 @@ export function getDefineEnv({
config.devIndicators.appIsrStatus config.devIndicators.appIsrStatus
), ),
'process.env.__NEXT_PPR': checkIsAppPPREnabled(config.experimental.ppr), 'process.env.__NEXT_PPR': checkIsAppPPREnabled(config.experimental.ppr),
'process.env.__NEXT_DYNAMIC_IO': !!config.experimental.dynamicIO,
'process.env.__NEXT_AFTER': config.experimental.after ?? false, 'process.env.__NEXT_AFTER': config.experimental.after ?? false,
'process.env.NEXT_DEPLOYMENT_ID': config.deploymentId || false, 'process.env.NEXT_DEPLOYMENT_ID': config.deploymentId || false,
'process.env.__NEXT_FETCH_CACHE_KEY_PREFIX': fetchCacheKeyPrefix ?? '', 'process.env.__NEXT_FETCH_CACHE_KEY_PREFIX': fetchCacheKeyPrefix ?? '',
......
...@@ -160,6 +160,11 @@ async function generateCacheEntry( ...@@ -160,6 +160,11 @@ async function generateCacheEntry(
} }
export function cache(kind: string, id: string, fn: any) { export function cache(kind: string, id: string, fn: any) {
if (!process.env.__NEXT_DYNAMIC_IO) {
throw new Error(
'"use cache" is only available with the experimental.dynamicIO config.'
)
}
const cacheHandler = cacheHandlerMap.get(kind) const cacheHandler = cacheHandlerMap.get(kind)
if (cacheHandler === undefined) { if (cacheHandler === undefined) {
throw new Error('Unknown cache handler: ' + kind) throw new Error('Unknown cache handler: ' + kind)
......
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