Throwing something other than `Unexpected token '<', "<!DOCTYPE "... is not valid JSON`

I'm trying to do custom error handling but whatever I throw just ends up being `Unexpected token '<', "<!DOCTYPE "... is not valid JSON`` Am I doing something weird here?
Solution:
I solved it through returning the error locally instead of throwing it
No description
BeBoRE
BeBoRE41d ago
Yes you aren’t hitting the tRPC endpoint
Samuel Barnholdt
Samuel Barnholdt41d ago
I am though, I can debug through the entire thing -> then something weird happens after throwing from inside
BeBoRE
BeBoRE41d ago
What does the response say?
Solution
Samuel Barnholdt
Samuel Barnholdt41d ago
I solved it through returning the error locally instead of throwing it
No description
NeoBean
NeoBean41d ago
i'm curious what happened here. If you're hitting trpc endpoint, trpc doesnt return html afaik. Or does it? Is this only happening in production/client? cloudflare/firewalls can return html page. Other than obviously the nextjs 404 page, which would mean youre indeed not hitting the endpoint
Samuel Barnholdt
Samuel Barnholdt41d ago
I think that what happened is that when I throw the error the endpoint either returns null or nothing at all
NeoBean
NeoBean41d ago
Umm. That wouldnt be Unexpected token '<', "<!DOCTYPE "... is not valid JSON tho. idk
Samuel Barnholdt
Samuel Barnholdt41d ago
this was the code previous
No description
Samuel Barnholdt
Samuel Barnholdt41d ago
yeah you're right, tried to find the argument to the JSON.parse that causes the bug but post throwing it's hard to follow
More Posts
Create client that is used in every request, without re-creating clientHi all, Consider the following ``` export const createContextInner = async ({ req, res, }: { Using TRPC Server Caller in client side.What's up TRPCer. so i'm currently working in vanilla react app with seperate backend in .NET, in pAnyone has successfully setup a websockets subscription with an input ?Hi guys, here is my environment: *** node v20.11.1 * yarn@4.1.0 * trpc 11.0.0-next-beta.294 * next 1Middleware context changes aren't applied to `responseMeta(opts)` optionsIn our middleware I extend the ctx like this: ```ts const public = t.middleware(async ({ next, ctx Cookie authentication flowHello can i get a bit of a help and explanation please? Im frontend learning backend on trpc, I haveIs It Possible to use methodOverride with createNextApiHandler?I'm trying to build queries for grids and filter and sort object could get very large which is exceeLambda container reuseIn high traffic environments lambda reuses the same container to serve multiple requests. The lambdaTrouble with Vercel and deployment URLHey I've been having a problem with nextjs deploying to vercel. In localhost the calls to the backen1 trpc api server for 1 or many clients.I'm a beginner, working on two monorepo projects that resides on the same folder, each of which withError formatting with trpcExpress.createExpressMiddlewareI'm trying to figure out how to do error formatting but it's unclear how to do it in the context of Tried to access "$types.prototype" which is not available at runtimeIm getting this weird errors every thing was good until I migrated to trpc 11 which for some reason type safety with metahow do I get the meta types to work correctly?Confused by the many examples and docs of implementing trpc, next.js (app router), and clerk.To show an examples of the many variants an implementations here is an example: In TRPC Docs: httpTypeError: cache is not a functionTrying to run vitest integration testing on a procedure but i keep running into errors with a "cacheCan't throw errorMy request is pending although throw new TRPCError() executed. Something wrong here?How to use `getQueryKey` from the server side?Hi guys, i cannot figure out how to use `getQueryKey` from the server side. Is this possible? The ukeep previous dataTrpc 11 (trpc@next) doesn’t have support for keepPreviousData? I’m trying to useQuery with keepPreviContext with trpc ws clientHello! I've implemented trpc to my nextjs 14 app router project, along with trpc socket subscriptionCannot use usemutation in my nextjs/t3 projectI have this code ` const mutation = api.auth.addaccount.useMutation(); const handleLogin = async Has anyone passed supabase user to the tRPC context in Expo?I am trying to pass the logged in user to the context of tRPC. To be able to use it in the routers a