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
When using a transformer (such as superjson as shown in the documenation), it is possible the transformation will fail.
I've tested this by using the fastify TRPC plugin and superjson transformer. Sending invalid input causes the server to always throw 500, since the parse error is thrown before ever making it to the procedures.
Right now I'm thinking that you have to make your own wrapper around the transformer's functions that fulfills the transformer interface:
// beforetransformer: superjson,// aftertransformer: {output: superjson,input: {serialize: superjson.serialize,deserialize(data){try{returnsuperjson.deserialize(data);}catch(err){thrownewTRPCError({code: 'PARSE_ERROR',cause: err,message: 'input was unable to be transformed',});}},},},
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When using a transformer (such as
superjson
as shown in the documenation), it is possible the transformation will fail.I've tested this by using the fastify TRPC plugin and superjson transformer. Sending invalid input causes the server to always throw 500, since the parse error is thrown before ever making it to the procedures.
Right now I'm thinking that you have to make your own wrapper around the transformer's functions that fulfills the transformer interface:
Thanks for any input you may have.
Beta Was this translation helpful? Give feedback.
All reactions