tRPCttRPC
Powered by
MugetsuM
tRPC•3y ago•
2 replies
Mugetsu

Enigmatic INTERNAL SERVER ERROR

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)
      },
    })
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Dockerized Next.JS Error [TRPCClientError] INTERNAL_SERVER_ERROR
AerilymAAerilym / ❓-help
16mo ago
Error: Switched to client rendering because the server rendering errored: UNAUTHORIZED
heyitsiveenHheyitsiveen / ❓-help
10mo ago