{"record":{"id":"3c54efa7942a8358","repo":"vercel/next.js","slug":"cachelife-can-only-be-called-during-app-router","errorCode":null,"errorMessage":"`cacheLife()` can only be called during App Router rendering at the moment.","messagePattern":"`cacheLife\\(\\)` can only be called during App Router rendering at the moment\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/use-cache/cache-life.ts","lineNumber":59,"sourceCode":"    case 'prerender-legacy':\n    case 'request':\n    case 'unstable-cache':\n    case 'generate-static-params':\n    case undefined:\n      throw createCacheLifeOutsideUseCacheError(\n        workAsyncStorage.getStore()?.route\n      )\n    case 'cache':\n    case 'private-cache':\n      break\n    default:\n      workUnitStore satisfies never\n  }\n\n  if (typeof profile === 'string') {\n    const workStore = workAsyncStorage.getStore()\n    if (!workStore) {\n      throw new Error(\n        '`cacheLife()` can only be called during App Router rendering at the moment.'\n      )\n    }\n\n    // TODO: This should be globally available and not require an AsyncLocalStorage.\n    const configuredProfile = workStore.cacheLifeProfiles[profile]\n    if (configuredProfile === undefined) {\n      if (workStore.cacheLifeProfiles[profile.trim()]) {\n        throw new Error(\n          `Unknown \\`cacheLife()\\` profile \"${profile}\" is not configured in next.config.js\\n` +\n            `Did you mean \"${profile.trim()}\" without the spaces?`\n        )\n      }\n      throw new Error(\n        `Unknown \\`cacheLife()\\` profile \"${profile}\" is not configured in next.config.js\\n` +\n          'module.exports = {\\n' +\n          '  cacheLife: {\\n' +\n          `    \"${profile}\": ...\\n` +","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/vercel/next.js/blob/258b1c1bc05f7099816b88f70b7b3422b24a4b8d/packages/next/src/server/use-cache/cache-life.ts#L41-L77","documentation":"Guard in cacheLife(): the profile argument was a string, but workAsyncStorage.getStore() returned no work store — the call is happening outside an App Router render request (no active request AsyncLocalStorage context, e.g. at module scope or in a plain Node context). Without the store the profile cannot be resolved against the route's configured cacheLife profiles, so the sentinel error fires.","triggerScenarios":"cacheLife() is called outside App Router rendering.","commonSituations":"Calling cacheLife() in a context without an active work unit, such as a route handler or action.","solutions":["Call cacheLife() only inside App Router rendering (a page/layout with \"use cache\")."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"258b1c1bc05f7099816b88f70b7b3422b24a4b8d","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}