From 83a4a0f19588d2d1dce0c8d733bd1c661a683984 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 27 Feb 2024 14:26:46 +0000 Subject: [PATCH] fix: change strategy for route caching --- .changeset/great-flowers-own.md | 5 +++++ packages/astro/src/core/render/route-cache.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/great-flowers-own.md diff --git a/.changeset/great-flowers-own.md b/.changeset/great-flowers-own.md new file mode 100644 index 000000000000..a2295691f2d2 --- /dev/null +++ b/.changeset/great-flowers-own.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes an issue where multiple injected routes with the same `entrypoint` but different `pattern` were incorrectly cached, causing some of them not being rendered in the dev server. diff --git a/packages/astro/src/core/render/route-cache.ts b/packages/astro/src/core/render/route-cache.ts index 8a4e821a523c..21e641220ffe 100644 --- a/packages/astro/src/core/render/route-cache.ts +++ b/packages/astro/src/core/render/route-cache.ts @@ -102,14 +102,14 @@ export class RouteCache { // NOTE: This shouldn't be called on an already-cached component. // Warn here so that an unexpected double-call of getStaticPaths() // isn't invisible and developer can track down the issue. - if (this.mode === 'production' && this.cache[route.component]?.staticPaths) { - this.logger.warn(null, `Internal Warning: route cache overwritten. (${route.component})`); + if (this.mode === 'production' && this.cache[route.route]?.staticPaths) { + this.logger.warn(null, `Internal Warning: route cache overwritten. (${route.route})`); } - this.cache[route.component] = entry; + this.cache[route.route] = entry; } get(route: RouteData): RouteCacheEntry | undefined { - return this.cache[route.component]; + return this.cache[route.route]; } }