You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes TRPC calls don't directly go to the TRPC server. Sometimes they go through proxies that process the request against rules including checking the authorization header.
If you don't control these proxies, they can return JSON that isn't in the format that TRPC expects which results in a formatting error.
For example, Supabase's edge functions return the following response on an invalid JWT.
{"msg": "Invalid JWT"}
This line fails because result.type doesn't exist in the json. The TRPC loggerLink then logs it like this.
In service of that, it would be nice to have one of the following
Ability to transform the json parsed without completely overhauling deserialization
Ability to introspect the json parsed for logging/debugging purposes
Describe alternate solutions
I attempted to use a custom link, but this error happens inside of the httpBatchLink itself and doesn't expose the json or error in what is returned down the chain.
I also looked at using the transformer option, but this isn't defined as of @trpc/client@10.45.2.
I considered overriding the fetch function that was used by TRPC, but it would be hard to transform the response since TRPC parses the json itself without giving the option for transformation
Additional information
No response
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR implementing this feature!
Funding
You can sponsor this specific effort via a Polar.sh pledge below
We receive the pledge once the issue is completed & verified
The text was updated successfully, but these errors were encountered:
constcustomLoggingLink=(): TRPCLink<AppRouter>=>()=>{return({ next, op })=>{returnobservable((observer)=>{returnnext(op).pipe(tap({error(err){constresponse=err?.meta?.response;},})).subscribe(observer);});};};
Describe the feature you'd like to request
Sometimes TRPC calls don't directly go to the TRPC server. Sometimes they go through proxies that process the request against rules including checking the authorization header.
If you don't control these proxies, they can return JSON that isn't in the format that TRPC expects which results in a formatting error.
For example, Supabase's edge functions return the following response on an invalid JWT.
This line fails because
result.type
doesn't exist in the json. The TRPCloggerLink
then logs it like this.Describe the solution you'd like to see
What I'd like to do is
In service of that, it would be nice to have one of the following
Describe alternate solutions
I attempted to use a custom link, but this error happens inside of the
httpBatchLink
itself and doesn't expose the json or error in what is returned down the chain.I also looked at using the transformer option, but this isn't defined as of
@trpc/client@10.45.2
.I considered overriding the
fetch
function that was used by TRPC, but it would be hard to transform the response since TRPC parses the json itself without giving the option for transformationAdditional information
No response
👨👧👦 Contributing
Funding
The text was updated successfully, but these errors were encountered: