Skip to content

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

@codeart1st

Description

@codeart1st

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions