T
tRPC

Why am I seeing 500 errors on responses to clients in production?

Why am I seeing 500 errors on responses to clients in production?

Cchirptune4/18/2023
I'm running my trpc server with NODE_ENV=production with the expressjs adapter, and I'm getting this in the response of a client. [{"error":{"message":"connect ECONNREFUSED 127.0.0.1:5432","code":-32603,"data":{"code":"INTERNAL_SERVER_ERROR","httpStatus":500,"path":"budget"}}}] I would expected the message to not show up, and just give a generic error message. Why don't these errors get written to stdout by default instead? Or maybe I don't have it setup correctly?
Solution:
You can use an errorFormatter to customise this
Jump to solution
Solution
Nnlucas4/18/2023
You can use an errorFormatter to customise this
Nnlucas4/18/2023
But it looks like it’s working as intended, internal errors get sent to the frontend, and in this case your DB connection is getting passed on because you haven’t otherwise handled it NODE_ENV should definitely vary some leakiness, I’d need to check how much it varies it With regards to STDERR, you can use onError in your adapter to log this out And I think only stacktrace info gets disabled by NODE_ENV https://trpc.io/docs/server/error-handling
Cchirptune4/18/2023
but shouldn't the message also be excluded? not just the stacktrace? I was hoping that I did a misconfig, or in an unlikely case, that it was a bug. I noticed I can config that out (although the only example is for next, I could potentially push a PL for that)
Nnlucas4/18/2023
It’s a feature rather than a bug, for a production app you should generally have a error formatter If we had strong default opinions it might stop you doing what you want, but this way you can be as strict as you like
Cchirptune4/18/2023
ok, I see thank you for your time

Looking for more? Join the community!

T
tRPC

Why am I seeing 500 errors on responses to clients in production?

Join Server
Recommended Posts
trpc auto refreshes page when I lose focusHi, i thought this was a development environment only configuration, but it does it even in productiIncorrect type errorsNo idea if this is a trpc issue, but i'm having a bit of a nightmare with type errors. Nothing is shtest post 2hello againquery debounceHey there ! I wonder if anyone could point me to a standard recipe to achieve query debouncing and Type of createServerSideHelpers?I'm currently trying to implement a helper for `getServerSideProps` to reduce duplication. It's stilhow to set request timeout in clientcreateProxyClient has no option about timeout like axios does. Just in one router request (query or trpc rate limitinghi I am currently having some problems with a race condition in my TRPC nextJS api. Essentially whtrpc pipe middlewareHey all. I'm currently trying to create a middle ware on endpoints using the new `pipe` API. This Has anyone ever used tRPC (with SSR) and i18n?No matter the lib (next-intl, next-i18n, next-translate), I simply stumble from one problem to anothNew to tRPC and Need Help with BasicsI made a new T3 app, but I don't quite understand how tRPC works, and I would love to get some help web socket keeps on disconnecting and connectingHi! Its my first time using web sockets. The first code snippet is my socket code. The second code sPagination QueryHi, I'm new for web dev and I'm moved to tRPC not so long I'm looking for example of pagination quEnrich the response object for TRPC endpointCurrently when I hit a trpc endpoint I get something like: ```typescript { result: { data:Can i fetch tRPC in different project@coco- : I Make a tRPC in my project. Can I use the enpoint api in different project ?Importing AppRouter types from an external repoI've got a production T3 app already in production. I've created a fresh expo app to start building TypeScript type for request object for route handlersSo far I've been writing my routes like: ```typescript export const router = t.router({ helloWorlTyped wrappers for proceduresI have a TRPC client with working queries and mutations. I wanted to create wrapper functions for alAre TRPC server procedures actual endpoints? Meaning can you directly do a `post` request to them?Lets say you have a public procedure called `getHelloWorld`, can you hit it by doing `localhost:3000TRPCClientError - No "query"-procedure on path "user.all"Im using react native expo, prisma, trpc and the postgres database is on railway I have run the follAm I the only one struggling with pnpm + TypeScript monorepo + trpc?Hello all, When using pnpm in a TypeScript monorepo without `node-linker`, I hit those errors: ```