Get tRPC Connection Status

Is there a way I can get the current connection status without having to create a specific query that regularly pings?
7 Replies
cje
cje2y ago
what do you mean by "connection status"?
ed.upton
ed.uptonOP2y ago
So when the server is no longer reachable I would like to notify the user and could be down to: - Lost internet connection - The t3 deployment having stopped
cje
cje2y ago
it works like a restful api, so there is no "connection"
ed.upton
ed.uptonOP2y ago
Yeah, that makes sense, so I guess the way to go is to have a ping query that I can call every second or so
cje
cje2y ago
how important is it to know this at all times? you could just handle it when a normal query fails
ed.upton
ed.uptonOP2y ago
Yeah, that is probably a better option, I thought I should add it since I stopped the dev server then started to wonder why stuff wasn't working as expected, and it turns out the specific thing I was trying to do did not handle the query failing
robotkutya
robotkutya2y ago
just throwing this in the mix, might be useful for you https://tanstack.com/query/v4/docs/react/guides/network-mode trpc uses tanstack query, and with tanstack query you can define different strategies how to handle offline stuff
Network Mode | TanStack Query Docs
TanStack Query provides three different network modes to distinguish how Queries and Mutations should behave if you have no network connection. This mode can be set for each Query / Mutation individually, or globally via the query / mutation defaults. Since TanStack Query is most often used for data fetching in combination with data fetching l...
Want results from more Discord servers?
Add your server