-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
🐛 BUG: dynamic route params as numbers break findPathItemByKey search #3082
Copy link
Copy link
Closed
Description
What version of astro are you using?
1.0.0-beta.7
Are you using an SSR adapter? If so, which one?
no
What package manager are you using?
npm
What operating system are you using?
mac
Describe the Bug
I had export function getStaticPaths() returning [{ year, month, slug }, ...] for a blog and got hit by this error:
error [getStaticPath] route pattern matched, but no matching static path found. (/blog/2014/04/asincron-a-y-el-eventloop/)
After some navigating astro's code I found the issue comes from findPathItemByKey() not being able to find a page with such params so I added this line to astro's code:
if (matchedStaticPath) {
return matchedStaticPath;
}
+ debug('test', Array.from(staticPaths.keyed.keys()))
debug("findPathItemByKey", `Unexpected cache miss looking for ${paramsKey}`);and a logger in my config file
globalThis._astroGlobalDebug = (...args) => console.log(...args);And got this printed out:
test [
'{"month":"04","slug":"asincron-a-y-el-eventloop","year":2014}',
...
]
findPathItemByKey Unexpected cache miss looking for {"month":"04","slug":"asincron-a-y-el-eventloop","year":"2014"}
Took me a while to find out the only difference is that year is a number in the cache while it's a string in the key we're looking for it's a string.
IMPORTANT: this is only visible with astro build
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-afsa7x?file=src/pages/[year].astro
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels