-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix(nuxt): use more performant router catchall pattern #31450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
WalkthroughThis pull request introduces changes to the Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@nuxt/kit
nuxt
@nuxt/schema
@nuxt/rspack-builder
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #31450 will not alter performanceComparing Summary
|
Hi @danielroe , TL;DR: After upgrading from Nuxt 3.15.4 to 3.17.5, nested catch-all routes are no longer being grouped as children but are instead being flattened into separate top-level routes, breaking our existing URL structure. I'm not directly opening a new issue, because I first want to understand if this is really an issue that needs to be fixed on the Nuxt side. We have the following structure: pages/ This would have generated something like this in [
{
"children": [
{
"children": [],
"file": "/[...layout]/index.vue",
"name": "layout",
"path": ""
},
{
"children": [],
"file": "/[...layout]/page-[page].vue",
"name": "layout-page-page",
"path": "page-:page()"
}
],
"file": "pages/[...layout].vue",
"path": "/:layout(.*)*"
}
] Now in [
{
"children": [
{
"children": [],
"file": "/[...layout]/index.vue",
"name": "layout",
"path": ""
}
],
"file": "/[...layout].vue",
"path": "/:layout(.*)*"
},
{
"children": [],
"file": "/[...layout]/page-[page].vue",
"meta": undefined,
"name": "layout-page-page",
"path": "/:layout([^/]*)*/page-:page()"
}
] As you can see, the The issue: This breaks our existing route structure where Basically, as it stands now I can't upgrade. Changing the URL structure isn't possible since our URLs are dynamically controlled by a CMS where admins can configure arbitrary layout/page combinations. We rely on the flexible nested catch-all routing structure to handle these dynamic CMS-generated routes. Please let me know if I should open an issue or if this was intended, thanks. |
you are right, this is a bug i believe there is an existing issue but it did not identify the cause, so it might be difficult to find |
@danielroe I think the issue is here, I cloned the repo and I'm playing around, basically I added this lines to pages.test.ts: [
{ path: `${pagesDir}/[...sub].vue` },
{ path: `${pagesDir}/[...sub]/index.vue` },
{ path: `${pagesDir}/[...sub]/route-[slug].vue` }
] Then I run the test in debug mode, I allow the first two entries to be processed which seems to correctly group them as parent child routes After a few steps we get here: The Problem:
Since these don't match exactly, the algorithm fails to recognize the parent-child relationship and creates the route as a separate top-level route instead of nesting it under the catch-all parent. I have no idea how to actually fix it though. Thanks |
Hello @danielroe , Let me know if you want me to create a new issue (I searched through the currently open issues, but I was unable to find one where I can reference my comments). Thanks |
@vsergiu93 please do 🙏 |
🔗 Linked issue
📚 Description
this improves catchall pattern to avoid polynomial/exponential backtracking when used in the middle of a route pattern (e.g.
~/pages/[...id]/other
) which in any case is an anti-pattern I would strongly advise avoiding.