TanStackT
TanStack16mo ago
4 replies
hurt-tomato

Best way to catch/handle errors during streaming

Hello, I am getting the error A query that was dehydrated as pending ended up rejecting. but I am unable to try/catch it and unsure of the best way to handle these errors.

snippet/example of what I am doing:
...
  queryClient.prefetchQuery(myQuery);

  return (
    <HydrationBoundary state={dehydrate(queryClient)}>
      {children}
    </HydrationBoundary>
  );


However, in this case it is throwing from a 404. I want to catch this and redirect. Given I am in a server component, I tried to try/catch with a redirect to no avail. It is just showing my error boundary.

What is the best way to handle this error? Or perhaps more specifically, how can I catch this error and redirect/do some other action?

Thanks!
Was this page helpful?