Skip to content
Source
Sign inSign up
TanStack/router

'Tried to render a redirected route match! This is a weird circumstance, please file an issue!' #7120

Closedcodeart1st(GitHub profile, opens in a new tab) opened this issue 8 comments

Which project does this relate to?

Router

Describe the bug

Throwing a redirect in root route beforeLoad with pendingComponent and pendingMs: 0 fail into 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!'

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-gvh2rqij?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

Open the stackblitz example. It should redirect to /posts and not showing a white page with an js error.

const rootRoute = createRootRoute({
  component: RootComponent,
  pendingMs: 0,
  pendingComponent: () => <div>loading</div>,
  beforeLoad: async () => {
    await new Promise((resolve) => setTimeout(resolve, 1000));
    const alreadyRedirected = sessionStorage.getItem(key) === 'true';
    sessionStorage.setItem(key, 'true');
    if (!alreadyRedirected) {
      throw redirect({ to: '/posts' });
    }
  },
  notFoundComponent: () => {
    return (
      <div>
        <p>This is the notFoundComponent configured on root route</p>
        <Link to="/">Start Over</Link>
      </div>
    );
  },
});

Expected behavior

Redirect works as expected in root route beforeLoad with pendingComponent and pendingMs: 0

Screenshots or Videos

Image

Platform

  • Router Version: 1.168.10
  • OS: Linux
  • Browser: Chrome
  • Browser Version: 146.0.7680.178
  • Bundler: vite
  • Bundler Version: 8.0.0

Additional context

No response

  1. codeart1st(GitHub profile, opens in a new tab)commented

    @schiller-manuel I upgraded the example, but the problem is still there: https://stackblitz.com/edit/tanstack-router-gvh2rqij?file=src%2Fmain.tsx

    package-lock.json:

    "node_modules/@tanstack/react-router": {
          "version": "1.168.15",
          "resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.168.15.tgz",
          "integrity": "sha512-V6evK+2d8r4VtaxNFT7I3ZUSPJegaXWoocCcIkAsFTBq66ymlD6FrNTOdl7qRB0I+ApFT1CGV3OMmzq5HgX74Q==",
    Image
  2. @schiller-manuel Does it help to contribute a failing unit test for this?

  3. My current workaround is removing pendingMs: 0 from my root route, but this leads to a white page during the initial load.

  4. We have problems with crashes in our app, constant crashing in e2e tests. I just wanted to leave a feedback that i tried to apply #7158 locally and it resolves the issue completely, thank you

  5. ryanagillie(GitHub profile, opens in a new tab)commented

    The "fix" we implemented was adding wrapInSuspense: true to our root route, but I'm not sure if that will affect other setups

  6. working on this here: #7158

    @schiller-manuel, is the change still in development, or is it just a lower priority right now?

  7. lower priority, but not forgotten

Sign in to join this conversation.