You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TrieRouter runs a handler twice when a path segment is literally * #5370
/a/b runs the middleware once. /a/* runs it twice.
This is reachable without choosing TrieRouter explicitly. SmartRouter falls back to it whenever RegExpRouter throws UnsupportedPathError, so this app on the default router hits it too:
In search(), a request part of * finds that node through node.#children[part] and pushes its handlers, then the #patterns loop reaches the same node and pushes them again. Any other part misses the #children lookup and only takes the pattern branch, which is why only a literal * duplicates.
The other three routers return the handler once for this path.
I have a fix that skips the pattern branch when it resolves to the node the #children lookup already handled, limited to the last segment so a wildcard still matches the rest of the path. Full suite passes and I added the case to common.case.test.ts, where all four routers pass it. Happy to open the PR.
This is also fixed by #5318, open since Aug 29. I ran the two tests from #5371 against that branch: both pass on every router, and on current main the TrieRouter case matches twice.
Activity
MahathirMohammadShuvo commentedon Sep 14, 2026
This is also fixed by #5318, open since Aug 29. I ran the two tests from #5371 against that branch: both pass on every router, and on current main the TrieRouter case matches twice.
yusukebe commentedon Sep 14, 2026
This issue is already fixed by #5318.
The PR will be merged in the next major release, v5.
fix(router): prevent TrieRouter from executing handlers twice on lite…