router icon indicating copy to clipboard operation
router copied to clipboard

Route match warnings (start/alpha)

Open danecando opened this issue 6 months ago • 12 comments

Which project does this relate to?

Start

Describe the bug

Under certain conditions, routes with dynamic parameters are logging match warnings when links are clicked.

This is reproduced in the start-basic example upgraded to the alpha release

posts.$postId.tsx:47 Could not find match for from: /posts/$postId

posts.$postId.tsx

47:   <Link
        to="/posts/$postId/deep"
        params={{
          postId: post.id,
        }}
        activeProps={{ className: "text-black font-bold" }}
        className="inline-block py-1 text-blue-800 hover:text-blue-600"
      >
        Deep View
      </Link>

Your Example Website or App

https://github.com/danecando/start-basic

Steps to Reproduce the Bug or Issue

  1. Start the alpha/devinxi start-basic example
  2. Navigate to /posts
  3. Click a link for one of the posts in the list
  4. Click the "Deep View" link in the post page

After clicking "Deep View" route match warning gets logged to the console

Expected behavior

As a user, I expect to be able to link to full paths in my route tree without console warnings

Screenshots or Videos

No response

Platform

  • OS: MacOS Sequoia 15.5
  • Browser: Chrome
  • Version: 136

Additional context

Confirmed that this issue cannot be reproduced in the main branch start-basic example or regular router basic examples

danecando avatar May 30 '25 22:05 danecando

I’m experiencing the same issue starting with the latest version 1.121.0.

lo1tuma avatar Jun 11 '25 07:06 lo1tuma

I see this issue as well:

Could not find match for from: /codelist/$code/

but I have route like this working well:

createFileRoute('/codelist/$code/')

I am using file routes.

tfilo avatar Jun 12 '25 11:06 tfilo

Also seeing this issue but it errors me back to the parent element

empotts avatar Jun 12 '25 17:06 empotts

I'm getting the same issue after having to manually delete my node modules and then npm install. I'm also getting a .tanstack/temp/router-generator-xyz folder being created with every npm run dev. The warnings seem to be related to the Link component. The routing works well with no issues. It is just these folders and the console warnings. I'm using file based routing (the router only not Start). It seems that auto-code splitting is also affected. previously I had 100+ chunks, now it is just 8.

kad5 avatar Jun 13 '25 22:06 kad5

Getting this issue also after upgrading to the latest.

alxlacayo avatar Jun 14 '25 07:06 alxlacayo

I am getting this warning after upgrading router to 1.121.12 not using start. Could not find match for from: /pathname/

merthanmerter avatar Jun 14 '25 20:06 merthanmerter

Also this seems to be happening with when navigating from basic routes to routes with dynamic params or vice versa. Navigating between two basic routes without any params, does not log the warning 🤔

whoisandy avatar Jun 15 '25 19:06 whoisandy

Also this seems to be happening with when navigating from basic routes to routes with dynamic params or vice versa. Navigating between two basic routes without any params, does not log the warning 🤔

This is what I am seeing as well. Navigating to and away from a route that has params (no problem with searchParams) gives this warning. It does not matter whether navigating by Link, through useNavigate or via browser back/forward.

Providing a from in the link does not help.

Nothing seems to be "broken", but the warnings are annoying and they give me the feeling something might not be working.

This problem has started since 1.121, I am using file based routing and not using Start but simple Vite config.

bdevos avatar Jun 17 '25 06:06 bdevos

Having the same issue on 1.121.21

jacobgad avatar Jun 17 '25 08:06 jacobgad

There might be something wrong with router.matchRoute. Starting with version v1.21.x, useMatchRoute (which uses router.matchRoute) returns different results.

gynekolog avatar Jun 17 '25 08:06 gynekolog

After (at least) five hours of debugging, I can say this router.matchRoute change is kinda breaking.

In our app (React SPA + Tanstack Router), some routes don't have .index files to determine the index of that route. Everything worked just fine up until 1.120.20.

After updating to the latest, out of nowhere, some routes were just being redirected to the root index (/). I thought it was a change in our code, and I have been trying to debug it ever since. After reading about this issue and downgrading to 1.120.20, the problem went away.

Even though it was a "minor update," it would be considered a breaking change that I wasn't aware of.

mathwcst-bitlyft avatar Jun 18 '25 14:06 mathwcst-bitlyft

@mathwcst-bitlyft can you please provide a reproducer for this? we did not intend to introduce any change here, so this is a bug then

schiller-manuel avatar Jun 18 '25 17:06 schiller-manuel

Sorry for the delay, I've been super overwhelmed at work. I will create the reproducer this weekend and update here.

mathwcst-bitlyft avatar Jun 20 '25 12:06 mathwcst-bitlyft

Can confirm that the issue does not appear in version 1.120.00.

icf-mrankin avatar Jun 20 '25 14:06 icf-mrankin

I also got the issue on a renovate PR, no Start, only Router, upgrading 1.120.17 -> 1.121.21

Sheraff avatar Jun 25 '25 20:06 Sheraff

It is easy to reproduce, just follow the Quick Start (https://tanstack.com/router/latest/docs/framework/react/quick-start#manual-setup), and add a Link component to about.tsx, then click the link you will see the warning in console

AlphaLiu avatar Jun 26 '25 06:06 AlphaLiu

We're encountering the same issue when upgrading from version 1.120.20 to >=1.121.0.

After debugging the router.ts file—specifically the section where the warning is logged—we noticed that this.latestLocation gets updated to the target location, while dest still retains a reference to the previous state. This mismatch causes the issue.

In the screenshot, you can see that dest correctly contains the expected to and from values. However, this.currentLocation has already been updated to the new destination. As a result, allFromMatches no longer includes the intended match, which leads to the warning being triggered.

Image

mihaerzen avatar Jul 01 '25 10:07 mihaerzen

issue as of 1.125.6

alexander-densley avatar Jul 08 '25 22:07 alexander-densley