{"record":{"id":"b23e5952500d3271","repo":"vercel/next.js","slug":"cache-no-store-used-on-fetch-for-fetchurl-wi","errorCode":null,"errorMessage":"cache: 'no-store' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-cache'","messagePattern":"cache: 'no-store' used on fetch for (.+?) with 'export const fetchCache = 'only-cache'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/lib/patch-fetch.ts","lineNumber":716,"sourceCode":"          case 'force-no-store': {\n            cacheReason = 'fetchCache = force-no-store'\n            break\n          }\n          case 'only-no-store': {\n            if (\n              currentFetchCacheConfig === 'force-cache' ||\n              (typeof finalRevalidate !== 'undefined' && finalRevalidate > 0)\n            ) {\n              throw new Error(\n                `cache: 'force-cache' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-no-store'`\n              )\n            }\n            cacheReason = 'fetchCache = only-no-store'\n            break\n          }\n          case 'only-cache': {\n            if (currentFetchCacheConfig === 'no-store') {\n              throw new Error(\n                `cache: 'no-store' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-cache'`\n              )\n            }\n            break\n          }\n          case 'force-cache': {\n            if (\n              typeof currentFetchRevalidate === 'undefined' ||\n              currentFetchRevalidate === 0\n            ) {\n              cacheReason = 'fetchCache = force-cache'\n              finalRevalidate = INFINITE_CACHE\n            }\n            break\n          }\n          case 'default-cache':\n          case 'default-no-store':\n          case 'auto':","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/lib/patch-fetch.ts#L698-L734","documentation":"Thrown by patch-fetch when a fetch() inside a route uses cache:'no-store' while the route declares `export const fetchCache = 'only-cache'`. The only-cache mode forbids uncached fetches, so the combination is contradictory and surfaces as a configuration error.","triggerScenarios":"A route file has `export const fetchCache = 'only-cache'` and inside it calls fetch(url, { cache: 'no-store' }). patch-fetch detects the conflict.","commonSituations":"Setting fetchCache='only-cache' to force caching but leaving a fetch that explicitly disables caching, or copying a dynamic fetch into a route that mandates caching.","solutions":["Change the conflicting fetch to { cache: 'force-cache' } or a positive revalidate to match the only-cache policy.","Or change/remove `export const fetchCache = 'only-cache'` if you need that fetch to stay dynamic.","Audit every fetch in the route so none use no-store."],"exampleFix":"// before\nexport const fetchCache = 'only-cache'\nexport default async function Page() {\n  const res = await fetch('https://api/x', { cache: 'no-store' }) // throws\n}\n\n// after\nexport const fetchCache = 'only-cache'\nexport default async function Page() {\n  const res = await fetch('https://api/x', { cache: 'force-cache' })\n}","handlingStrategy":"validation","validationCode":"// If fetchCache = 'only-cache', no fetch may use cache: 'no-store'","typeGuard":"function fetchCacheAllowsNoStore(mode: string): boolean {\n  return mode !== 'only-cache'\n}","tryCatchPattern":"null","preventionTips":["When setting fetchCache = 'only-cache', ensure no fetch uses no-store.","Audit fetch calls whenever changing the page cache mode.","Add a comment documenting why only-cache was chosen."],"tags":["fetch","fetch-cache","config-conflict"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}