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
sensitive-blueOP•2mo ago
it looks like onSubmit will propagate errors to the global error boundary, but granular validation functions will not
vicious-gold•2mo 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?
sensitive-blueOP•2mo ago
soooo
#TIL that queryClient.fetchQuery throwing does not propagate to global boundaries
that's my actual issue.. nothing to do with tanstack form!
vicious-gold•2mo ago
it doesnt??
I guess we both learned something then
sensitive-blueOP•2mo ago
Ya gotta wrap it in a useMutation
Or do useQuery with enabled false and trigger later
quickest-silver•2mo 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:...
sensitive-blueOP•2mo 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