We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Router
First of all, I'm sorry if the title of the issue does not describe what is happening.
I have two routes:
fetch
Both calls forward the abortController.signal to fetch to ensure the request is canceled if necessary.
abortController.signal
The index route is displaying a text input, and whenever the user types something, navigate is used which triggers a route reload.
navigate
If too many reloads are run, the error message "signal is aborted without reason" is triggered from the root view.
https://stackblitz.com/edit/tanstack-router-juizcyv2?file=src%2Froutes%2Findex.tsx
The abort error should be caught.
root.tsx:
import * as React from 'react'; import { Link, Outlet, createRootRoute } from '@tanstack/react-router'; import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'; export const Route = createRootRoute({ component: RootComponent, loader: async ({ abortController }) => { try { const data = await fetch('https://httpstat.us/200?sleep=1000', { signal: abortController.signal, }); } catch (e) { console.log('in __root, aborted'); throw e; } }, }); function RootComponent() { return ( <> <div className="p-2 flex gap-2 text-lg"> <Link to="/" activeProps={{ className: 'font-bold', }} activeOptions={{ exact: true }} > Home </Link>{' '} <Link to="/about" activeProps={{ className: 'font-bold', }} > About </Link> </div> <hr /> <Outlet /> <TanStackRouterDevtools position="bottom-right" /> </> ); }
index.tsx:
import * as React from 'react'; import { createFileRoute } from '@tanstack/react-router'; type Search = { filter: string; }; export const Route = createFileRoute('/')({ component: HomeComponent, validateSearch: (search: Record<string, unknown>): Search => { return { filter: (search.filter as string) || '', }; }, loaderDeps: ({ search }) => { return { filter: search.filter, }; }, loader: async ({ deps, abortController }) => { console.log('loading', deps.filter); try { const data = await fetch('https://httpstat.us/200?sleep=1000', { signal: abortController.signal, }); } catch (e) { console.log('in index, signal aborted for', deps.filter); throw e; } console.log('loaded:', deps.filter); return { status: 'loaded: ' + deps.filter }; }, }); function HomeComponent() { const search = Route.useSearch(); const navigate = Route.useNavigate(); const data = Route.useLoaderData(); return ( <div className="p-2"> <h3>Welcome Home!</h3> <h4>Status: {data.status}</h4> <input className="bg-gray-300 border border-black" value={search.filter} onChange={(e) => { navigate({ to: '/', search: { filter: e.target.value, }, }); }} /> </div> ); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Which project does this relate to?
Router
Describe the bug
First of all, I'm sorry if the title of the issue does not describe what is happening.
I have two routes:
fetch
to a slow APIfetch
to a slow APIBoth calls forward the
abortController.signal
tofetch
to ensure the request is canceled if necessary.The index route is displaying a text input, and whenever the user types something,
navigate
is used which triggers a route reload.If too many reloads are run, the error message "signal is aborted without reason" is triggered from the root view.
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-juizcyv2?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
Expected behavior
The abort error should be caught.
Screenshots or Videos
Screen.Recording.2025-04-03.at.13.41.43.mov
Platform
Additional context
root.tsx:
index.tsx:
The text was updated successfully, but these errors were encountered: