T
TanStack5mo ago
xenial-black

propagating errors to global error boundary

I am running a queryClient.fetchQuery inside of an onChange validator... when it throws a server error, I want it to use my global error boundary, but I'm noticing that it's getting swallowed and is just getting set to the localized error object, is there a way around this?
7 Replies
xenial-black
xenial-blackOP5mo ago
it looks like onSubmit will propagate errors to the global error boundary, but granular validation functions will not
harsh-harlequin
harsh-harlequin5mo ago
if it's an error that should propagate outside of your form, then why use a form-scoped validator? are you perhaps looking for a form listener instead?
xenial-black
xenial-blackOP5mo ago
soooo #TIL that queryClient.fetchQuery throwing does not propagate to global boundaries that's my actual issue.. nothing to do with tanstack form!
harsh-harlequin
harsh-harlequin5mo ago
it doesnt?? I guess we both learned something then
xenial-black
xenial-blackOP5mo ago
Ya gotta wrap it in a useMutation Or do useQuery with enabled false and trigger later
extended-salmon
extended-salmon5mo ago
That does not sound right... https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchquery
It will either resolve with the data or throw with the error.
Why wouldn't it propagate up to the nearest error boundary
QueryClient | TanStack Query Docs
QueryClient The QueryClient can be used to interact with a cache: tsx import { QueryClient } from '@tanstack/react-query' const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime:...
xenial-black
xenial-blackOP5mo ago
Maybe it’s an issue with how I have error handling configured Cause just throwing an error straight up doesn’t go to the error boundary

Did you find this page helpful?