YousefShanawany
YousefShanawany5mo ago

Useless TRPC Error messages: Error: ❌ tRPC failed on <no-path>

Environment * Node: v20.12.2 * Package manager: pnpm * Stack: T3 Stack * Environment: localhost * "@trpc/client": "^11.0.0-rc.446", * "@trpc/react-query": "^11.0.0-rc.446", * "@trpc/server": "^11.0.0-rc.446", Hey everyone. I've been struggling with this for too long now and would appreciate some help. When ever a TRPC endpoint errors, I can never find the error message in the logs and it makes debugging extremely difficult. For example: Server
export const testRouter = createTRPCRouter({
procedure: publicProcedure.query(() => {
throw new Error("❌❌❌❌❌ Test error");
})
});
export const testRouter = createTRPCRouter({
procedure: publicProcedure.query(() => {
throw new Error("❌❌❌❌❌ Test error");
})
});
Client
const { error: testError } = api.test.procedure.useQuery();
console.log(testError);
const { error: testError } = api.test.procedure.useQuery();
console.log(testError);
Error outputs Browser console log:
TRPCClientError: Invalid response or stream interrupted
Terminal console log:
Error: ❌ tRPC failed on <no-path>:
And
⨯ src/app/api/trpc/[trpc]/route.ts (27:17) @ Error ⨯ unhandledRejection: Error: ❌ tRPC failed on <no-path>: at Object.onError (webpack-internal:///(rsc)/./src/app/api/trpc/[trpc]/route.ts:43:19)
These error messages are really hard to trace to the correct line in my trpc procedures. Why doesn't it just output my error message in the Error I threw? How do I get more specific error messages? Every TRPC error I get shows the same output. I looked through the long list of terminal outputs and I don't see my error messages anywhere. This makes debugging extremely difficult. Thank you.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?