T
tRPC

How do I log thrown errors from the query/ mutation on the server side globally?

How do I log thrown errors from the query/ mutation on the server side globally?

Ttheo.gravity6/10/2023
I was surprised to find that the server servicing tRPC requests do not log any thrown errors from a query / mutation to the console by default (but the client does capture errors). I want to be able to log all errors on the server side. How would I do this? This page doesn't really give me any clues as I don't know what trpcNext.createNextApiHandler refers to: https://trpc.io/docs/server/error-handling#handling-errors I am using the express adapter with tRPC. I do not want to have to attach an error handling function to each query / mutation I define.
Nnlucas6/10/2023
All the adapters have an onError callback so you can use that Look at the docs for your adapter
Ttheo.gravity6/10/2023
Nnlucas6/10/2023
It might not be directly documented in this case, but it’s there and your editor autocomplete is all the docs you really need, get your editor to list all the options you can pass to the adapter
Ttheo.gravity6/12/2023
Typing on did help in the autocomplete for the adapter, thanks
trpcExpress.createExpressMiddleware({
router: appRouter,
createContext,
onError({ error, ctx }) {

},
trpcExpress.createExpressMiddleware({
router: appRouter,
createContext,
onError({ error, ctx }) {

},

Looking for more? Join the community!

T
tRPC

How do I log thrown errors from the query/ mutation on the server side globally?

Join Server
Recommended Posts
trpc with app dir nextjsHello im wondering how to use trpc with nextjs app router now?. I have t3 app but for now its a src/if I export 'appRouter' instead of 'router' I get errorhey everyone, I have this exact setup https://icflorescu.github.io/trpc-sveltekit/getting-started I React Native/Expo: Uncaught Error: No QueryClient set, use QueryClientProvider to set oneFound this issue but it just says to use patch-package, I was wondering if there was any changes sinAll values in DecoratedProcedureRecord are of type anyI've stumbled across an issue and I'm not sure how to start diagnosing it... Basically in my IDE tDetecting batch queries/mutations on the server-sideHello all, Looking to leverage batching as a means to streamline some of our cross-service requests,VS Code becomes unresponsiveHello everyone, I've started to experience huge performance issues with my project that's based onMiddleware-ish for clientHi! I had a quick question about client-side usage: I have users with long-running sessions, and iWhy cannot I specify a mutation input with useQueryKey?It's supported with queries, but for some reason not with mutations. Why is this the case?how to connect trpc server (t3 stack) from my external nextjs app?how to connect trpc server (t3 stack) from my external nextjs app?trpc.legacyRouterName.procedure "does not exist" on type CreateTRPCNextBase, runs anywayHave reached the end of a massive trpc 9 -> trpc 10 migration, executed using the official guide witNot getting legacy router ops in merged tRPC 9 routerFollowed the guide to merge my large tRPC 9 router with tRPC 10, but now I can't use useQuery or acccreateTRPCNext Type Error + useQuery Not DefinedI'm trying to use the conventions for `createTRPCNext ` from https://github.com/trpc/examples-next-pRead response headers on the clientIve been searching for a while trying to figure out how to access response headers on the client. FoIs it possible to access context in input?Hi, I have a validator that requires to get context of prisma in the `input`, Is it possible to get TRPCContextState not found in v10In our v9 app, we used TRPCContextState from internals to type out TRPC utils, importing it like `imRateLimiter for fastify tRPC routesHi, I would like to add Ratelimiter to a specific fastify trpc route, are there any solutions availaSubscriptionsare we able to send data over with subscriptions, to allow for full duplex communication ?Query tRPC the right wayIf you use graphql, you can precisely query what you exactly need and avoid over fetching, so you ca