{"record":{"id":"abaf6860a028f359","repo":"withastro/astro","slug":"astro-locals-runtime-caches-has-been-removed-in-as","errorCode":null,"errorMessage":"Astro.locals.runtime.caches has been removed in Astro v6. Use the global 'caches' object instead.","messagePattern":"Astro\\.locals\\.runtime\\.caches has been removed in Astro v6\\. Use the global 'caches' object instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/integrations/cloudflare/src/utils/cf-helpers.ts","lineNumber":82,"sourceCode":"export function createLocals(ctx: ExecutionContext): Runtime {\n\tconst locals: Runtime = {\n\t\tcfContext: ctx,\n\t};\n\tObject.defineProperty(locals, 'runtime', {\n\t\tenumerable: false,\n\t\tvalue: {\n\t\t\tget env(): never {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Astro.locals.runtime.env has been removed in Astro v6. Use 'import { env } from \"cloudflare:workers\"' instead.`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tget cf(): never {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Astro.locals.runtime.cf has been removed in Astro v6. Use 'Astro.request.cf' instead.`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tget caches(): never {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Astro.locals.runtime.caches has been removed in Astro v6. Use the global 'caches' object instead.`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tget ctx(): never {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Astro.locals.runtime.ctx has been removed in Astro v6. Use 'Astro.locals.cfContext' instead.`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t});\n\treturn locals;\n}\n\n/**\n * Extracts the client IP address from the `cf-connecting-ip` header.\n */\nexport function getClientAddress(request: Request): string | undefined {\n\treturn getValidatedIpFromHeader(request.headers.get('cf-connecting-ip'));","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/integrations/cloudflare/src/utils/cf-helpers.ts#L64-L100","documentation":"Thrown by `@astrojs/cloudflare` (v6+) when user code accesses `Astro.locals.runtime.caches`. The old `runtime.caches` (the Cloudflare Cache API) has been removed from the locals shim; the non-enumerable `runtime` property's `caches` getter always throws, directing users to the global `caches` object instead.","triggerScenarios":"Calling `Astro.locals.runtime.caches.default.match(...)` or `runtime.caches.open(...)` in a worker under the Cloudflare adapter on Astro v6. Any read of `caches` on `locals.runtime` triggers the throw.","commonSituations":"Upgrading a v5 project that used edge caching via `runtime.caches`. Copy-pasting v5 caching examples. The global `caches` is already available in the worker runtime, so the locals indirection was redundant and is now removed.","solutions":["Replace `Astro.locals.runtime.caches` with the global `caches` (already in scope in the worker).","Search for `runtime.caches` across the project.","Confirm `caches` global typing is available (provided by `@cloudflare/workers-types`)."],"exampleFix":"// before\nexport const GET = async ({ locals }) => {\n  const cache = locals.runtime.caches.default;\n  return cache.match(new Request('https://example.com'));\n};\n\n// after\nexport const GET = async () => {\n  const cache = caches.default;\n  return cache.match(new Request('https://example.com'));\n};","handlingStrategy":"validation","validationCode":"// Prebuild check for runtime.caches usage.\nconst { execSync } = require('child_process');\nconst out = execSync('grep -rn \"runtime\\\\.caches\" src/ || true').toString();\nif (out) { console.error('Migrate runtime.caches to global caches'); process.exit(1); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Replace `locals.runtime.caches` with the global `caches` object in v6.","Ensure @cloudflare/workers-types is installed for `caches` typing.","Centralize cache access in one helper module to ease future migrations."],"tags":["cloudflare","astro-v6","migration","breaking-change","caching"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}