2matto
2matto
Explore posts from servers
TtRPC
Created by 2matto on 3/16/2024 in #❓-help
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)
7 replies
TTCTheo's Typesafe Cult
Created by 2matto on 7/1/2023 in #questions
Use Edge Runtime by default??
I want to experiment with a project that is using t3 stack + the Edge Runtime: (So far I've got create-t3-app + database.js + clerk deployed to vercel) In Theo's video on Edge Runtime he shows nextConfig.experimental.runtime: experimental-edge as a way of using Edge by default, and mentions it would likely soon be deprecated. That option is no longer in the type-defs, so I assume it indeed has been deprecated. Does that mean the only way to make an entire app use the Edge Runtime is to export the runtime and region in every single entry point?
export const config = { runtime: 'edge', regions: ['iad1'] };
export const config = { runtime: 'edge', regions: ['iad1'] };
https://vercel.com/docs/concepts/functions/edge-functions#regional-edge-function-invocation
1 replies