Skip to content

Commit

Permalink
fix: change strategy for route caching
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Feb 27, 2024
1 parent bc2bf46 commit 83a4a0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-flowers-own.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 4 additions & 4 deletions packages/astro/src/core/render/route-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand Down

0 comments on commit 83a4a0f

Please sign in to comment.