Riccardo
Riccardo2mo ago

TRPC Error does not say router path

Hello, I have a tRPC client that sometimes fails to call my procedures/queries. I have many of them and find difficult to track back the router path that failed. Am I missing something? In the stacktrace I only get this: TRPCClientError: Unexpected token 'A', "An error o"... is not valid JSON at TRPCClientError.from (file:///voice/nodemodules/.pnpm/@trpc+client@11.0.0-rc.364@trpc+server@11.0.0-rc.364/node_modules/@trpc/client/dist/TRPCClientError.mjs:37:16) at file:///voice/nodemodules/.pnpm/@trpc+client@11.0.0-rc.364@trpc+server@11.0.0-rc.364/node_modules/@trpc/client/dist/links/internals/httpUtils.mjs:138:36 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { meta: { response: Response { [Symbol(realm)]: null, [Symbol(state)]: [Object], [Symbol(headers)]: [HeadersList] } }, shape: undefined, data: undefined, [cause]: SyntaxError: Unexpected token 'A', "An error o"... is not valid JSON at JSON.parse (<anonymous>) at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19) at successSteps (node:internal/deps/undici/undici:5555:27) at fullyReadBody (node:internal/deps/undici/undici:1665:9) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async specConsumeBody (node:internal/deps/undici/undici:5564:7)
11 Replies
alessandroooo
alessandroooo2mo ago
Don't you get the error in console or in the network tab? From there you should see the path it should look something like POST http://localhost..../path.to.api
Riccardo
RiccardoOP2mo ago
I log the error and that is what I get :/
alessandroooo
alessandroooo2mo ago
No description
alessandroooo
alessandroooo2mo ago
don't youy see something like that? probably you have them hidden
Riccardo
RiccardoOP2mo ago
I do no have access to the browser console log. The logs are in production. I catch the error and then console.log(error)
alessandroooo
alessandroooo2mo ago
is this a mutation?
Riccardo
RiccardoOP2mo ago
I do not know! I have mutations and queries
alessandroooo
alessandroooo2mo ago
ah hold on, you don't know which one gives errors, did i understand correctly?
Riccardo
RiccardoOP2mo ago
Seems wrong that the path information is not included in the error Object. Is there a way to include it? Maybe in the config?
alessandroooo
alessandroooo2mo ago
bot sure because i always see them. Maybe it doesnt work in production only
Riccardo
RiccardoOP2mo ago
I have catch on every mutation/query and console log the error (Which I then save in cloudwatch) Maybe I got it, tha path information is probably inside [Object]

Did you find this page helpful?