tRPC query eating all DB connections upon window refresh

We're building with T3, on one specific page, there are 7 separate query calls. If you tab out of the browser and tab back in, the refetchOnWindow focus will fire all the queries to fetch. This will work fine for the first 2-3 tab in/outs, after which the query will go out, but will never come back(request is just stuck as pending in the network tab) Disabling refetchOnWindowFocus for one specific query seems to help(reduces the occurrence of this bug by about 80%), but it's really weird because it's such a simple query I don't really see how there could be anything wrong with it
getHospitals: userProcedure.query(async ({ ctx: { db } }) => {
return await db.query.hospital.findMany();
}),
getHospitals: userProcedure.query(async ({ ctx: { db } }) => {
return await db.query.hospital.findMany();
}),
Disabling refetchOnWindowFocus for other queries doesn't really seem to help much. I think the underlying problem is that the DB connection isn't closing after these refetches come back, and so by like the 4th tab in/out, all the DB connections are saturated. Only way to resolve is to kill the dev server and restart. Tried turning on abortOnUnmount, did not seem to help at all Would really appreciate any insight you might have! See image for an example of all the queries coming back, and then they just stop coming back after like the 3rd tab in/out. Queries 22-27 never come back
No description
1 Reply
Lukem121
Lukem1212mo ago
const { data: keys } = api.key.getAll.useQuery(undefined, { refetchOnMount: false, refetchOnWindowFocus: false, });
Want results from more Discord servers?
Add your server