T
tRPC

Enigmatic INTERNAL SERVER ERROR

Enigmatic INTERNAL SERVER ERROR

MMugetsu3/24/2023
Im having a problem finding out about what is causing the INTERNAL SERVER ERROR from tRPC in my production. This is the error 👀
{
"level": "error",
"message": {
"cause": {},
"code": "INTERNAL_SERVER_ERROR",
"name": "TRPCError"
},
"timestamp": "2023-03-23T12:14:12.710Z",
"traceId": "...."
}
{
"level": "error",
"message": {
"cause": {},
"code": "INTERNAL_SERVER_ERROR",
"name": "TRPCError"
},
"timestamp": "2023-03-23T12:14:12.710Z",
"traceId": "...."
}
Are there any recommendation on how to handle onError handler for production ?? This is my current approach which seems to swallow some information. Can't really tell where it originates and how to possibly overcome it
trpcExpress.createExpressMiddleware({
router: appRouter,
createContext: createTRPCContext,
onError: ({ path: errorPath, error, ctx }) => {
const message = isDevelopment
? `❌❌❌ tRPC failed on ${errorPath ?? '<no-path>'}: ${
error.message
}`
: error

if (error.code === 'INTERNAL_SERVER_ERROR')
ctx.req.logger.error(message)
else ctx.req.logger.warn(message)
},
})
trpcExpress.createExpressMiddleware({
router: appRouter,
createContext: createTRPCContext,
onError: ({ path: errorPath, error, ctx }) => {
const message = isDevelopment
? `❌❌❌ tRPC failed on ${errorPath ?? '<no-path>'}: ${
error.message
}`
: error

if (error.code === 'INTERNAL_SERVER_ERROR')
ctx.req.logger.error(message)
else ctx.req.logger.warn(message)
},
})
Nnlucas3/24/2023
Surely pass the original error to your logger? That way it can format the stacktrace etc
MMugetsu3/27/2023
Yeah. I found that logger was not configured properly and not processing errors object 🤦‍♂️🤦‍♂️

Looking for more? Join the community!

T
tRPC

Enigmatic INTERNAL SERVER ERROR

Join Server