{"record":{"id":"ad384bed16506dbb","repo":"vercel/next.js","slug":"route-workstore-route-used-unstable-prefetch-ad384b","errorCode":null,"errorMessage":"Route ${workStore.route} used `unstable_prefetch()` inside a function cached with `unstable_cache()`. The `unstable_prefetch()` function is used to indicate the subsequent code must not run in the app shell, but `unstable_cache()` caches must be able to be produced before a prefetch, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache","messagePattern":"Route (.+?) used `unstable_prefetch\\(\\)` inside a function cached with `unstable_cache\\(\\)`\\. The `unstable_prefetch\\(\\)` function is used to indicate the subsequent code must not run in the app shell, but `unstable_cache\\(\\)` caches must be able to be produced before a prefetch, so this function is not allowed in this scope\\. See more info here: https://nextjs\\.org/docs/app/api-reference/functions/unstable_cache","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/cache-stages.ts","lineNumber":133,"sourceCode":"      const error = new Error(\n        `Route ${workStore.route} used \\`unstable_prefetch()\\` inside \"use cache\". This is not currently supported. Instead, move the \"use cache\" directive to a function that's called below \\`await unstable_prefetch()\\`, so that the cached content is deferred to the prefetch without caching the stage boundary itself. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`\n      )\n      Error.captureStackTrace(error, unstable_prefetch)\n      applyOwnerStack(error)\n      workStore.invalidDynamicUsageError ??= error\n      throw error\n    }\n    case 'private-cache': {\n      const error = new Error(\n        `Route ${workStore.route} used \\`unstable_prefetch()\\` inside \"use cache: private\". This is not currently supported. Instead, move the \"use cache\" directive to a function that's called below \\`await unstable_prefetch()\\`, so that the cached content is deferred to the prefetch without caching the stage boundary itself. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`\n      )\n      Error.captureStackTrace(error, unstable_prefetch)\n      applyOwnerStack(error)\n      workStore.invalidDynamicUsageError ??= error\n      throw error\n    }\n    case 'unstable-cache': {\n      throw new Error(\n        `Route ${workStore.route} used \\`unstable_prefetch()\\` inside a function cached with \\`unstable_cache()\\`. The \\`unstable_prefetch()\\` function is used to indicate the subsequent code must not run in the app shell, but \\`unstable_cache()\\` caches must be able to be produced before a prefetch, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`\n      )\n    }\n    case 'generate-static-params': {\n      throw new Error(\n        `Route ${workStore.route} used \\`unstable_prefetch()\\` inside \\`generateStaticParams\\`. This is not supported because \\`generateStaticParams\\` runs at build time without a prefetch. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context`\n      )\n    }\n    case 'prerender-client':\n    case 'validation-client': {\n      const exportName = '`unstable_prefetch`'\n      throw new InvariantError(\n        `${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`\n      )\n    }\n    case 'prerender-legacy': {\n      // NOTE: Should not be reachable, because we don't use this mode in cacheComponents,\n      // which we require at the top","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/vercel/next.js/blob/258b1c1bc05f7099816b88f70b7b3422b24a4b8d/packages/next/src/server/request/cache-stages.ts#L115-L151","documentation":"Error \"Route ${workStore.route} used `unstable_prefetch()` inside a function cached with `unstable_cache()`. The `unstable_prefetch()` function is used to indicate the subsequent code must not run in the app shell, but `unstable_cache()` caches must be able to be produced before a prefetch, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache\" thrown in vercel/next.js.","triggerScenarios":"Thrown at packages/next/src/server/request/cache-stages.ts:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the 'use cache' directive off the function containing unstable_prefetch() and onto a function called below 'await unstable_prefetch()', so the cached content is deferred without caching the stage boundary","Restructure so the unstable_cache()'d function no longer calls unstable_prefetch()","Remove unstable_prefetch() from the cached function if the prefetch stage is not needed there"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"258b1c1bc05f7099816b88f70b7b3422b24a4b8d","analyzedAt":"2026-08-21T19:56:13.433Z","contentChangedAt":"2026-08-21T19:56:13.433Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}