2matto
2matto5mo ago

Where to put clean up code?

I have a DB connection setup in my createContext that I must explicitly close per-request. But I cannot find any good spots in the TRPC lifecycle to make that call. I tried just running it in a middleware, but seemingly that is invoked on each query in a batch independently, whereas I need it to be called once all queries have finished. FWIW: I am using create-t3-app with @vercel/postgres and createClient. Any insight would be appreciated! (There is a similar post from a few years ago that went unanswered, though it was fastify-specific https://discord.com/channels/867764511159091230/1049691729516843048/1049691729516843048)
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
3 Replies
BeBoRE
BeBoRE5mo ago
Would also like to know if this is possible as well, would need to be documented well tho, cleanup of the context shouldn't be used for finishing transactions for instance.
IceAge2OnDVD
IceAge2OnDVD3mo ago
Looking to do the same with Neon DB, any updates?
BeBoRE
BeBoRE3mo ago
Procedures can clean up, createContext cannot Maybe with using? #tRPC context, NeonDB & WebSockets
More Posts
Trigger lambda configured with trpc using other eventsCan I trigger a lambda configured with trpc api gateway adapter using events other than httpApi likeuseInfiniteQuery does not exist on appRouter t3-Stack PrismaI'm using appRouter and trying to do pagination with useInfiniteQuery() but i've got the next typescDatadog tracesHey, has anyone had any luck setting up tracing with tRPC? Specifically with dd-trace-js. We’re usiAsynchronous subscribe and unsubscribe methods in observableHello, I have been looking at the documentation about subscriptions but I am not sure about one thitrpc v11 error: The transformer property has moved to httpLink/httpBatchLink/wsLinkJust upgraded tRPC to v11 and I directly got this error: Type typeof SuperJSON is not assignable to Typescript optimisationI'm trying to optimise the generated types from the router, as I see that lots of types for context Is it possible to change how TRPC maps routers to URL paths?Hello there, in my current project I would like to map merged routers to subpaths in the url. For eCreate user on the function mutate, with TRPC and PayloadHi everyone, I have faced issues with create user on the function mutate, with TRPC, I cant trace anHow to not prefetch on getServerSideProps if it's already fetched?I have a `getServerSideProps` that utilizes `createServerSideHelpers`, and when I access a page I prReturn undefined if param is not thereIn this code cityById could be undefined and I want that this checks this and then weatherData gets