vercel/next.js · error
Route ${workStore.route} used "${expression}" inside a funct
Error message
Route ${workStore.route} used "${expression}" inside a function cached with `unstable_cache()`. The enabled status of `draftMode()` can be read in caches but you must not enable or disable `draftMode()` inside a cache. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache What it means
Error "Route ${workStore.route} used "${expression}" inside a function cached with `unstable_cache()`. The enabled status of `draftMode()` can be read in caches but you must not enable or disable `draftMode()` inside a cache. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache" thrown in vercel/next.js.
Source
Thrown at packages/next/src/server/request/draft-mode.ts:222
throw new StaticGenBailoutError(
`Route ${workStore.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`
)
}
if (workUnitStore) {
switch (workUnitStore.type) {
case 'cache':
case 'private-cache': {
const error = new Error(
`Route ${workStore.route} used "${expression}" inside "use cache". The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`
)
Error.captureStackTrace(error, constructorOpt)
applyOwnerStack(error)
workStore.invalidDynamicUsageError ??= error
throw error
}
case 'unstable-cache':
throw new Error(
`Route ${workStore.route} used "${expression}" inside a function cached with \`unstable_cache()\`. The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
)
case 'prerender':
case 'prerender-runtime': {
const error = new Error(
`Route ${workStore.route} used ${expression} without first calling \`await connection()\`. See more info here: https://nextjs.org/docs/messages/next-prerender-sync-headers`
)
return abortAndThrowOnSynchronousRequestDataAccess(
workStore.route,
expression,
error,
workUnitStore
)
}
case 'prerender-client':
case 'validation-client':
const exportName = '`draftMode`'View on GitHub (pinned to 0eb3775416)
Solutions
- Do not enable/disable draftMode() inside unstable_cache; read isEnabled only, or move mutation outside the cache.
Defensive patterns
Strategy: validation
When it happens
Trigger: draftMode enable/disable is called inside unstable_cache.
Common situations: Mutating draft mode inside a cached function; only reading the enabled status is allowed.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/2c4fed8261753778.
Report an issue: GitHub.