Replies: 2 comments 2 replies
-
Thanks for sharing @tclain, would you be open to creating a PR to the docs in the appropriate place? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I was having this problem and resolved it by adding
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there ! thanks for the awesome lib !
I have lost a bit of time the past couple of day so I'd figured I would share my story and my resolutions for the record.
I have been deploying my trpc router in express in a serverless context, specifiically with
@vendia/serverless-express
. something like:Locally when running project through the default express listener, everything is fine. but as I soon as I would deploy even the simplest of mutation in aws lambdas, I would get this error:
Wait what 😱 ??
i Have no number at all in my mutation but the error says it is received a number. When debugging this number was "123".
So I went into the rabbit hole and it turns out that the serverless handler parses
req.body
as a.... Buffer, not a string and it seems trpc expect a string.So in
resolveHTTPResponse
instead of receiving:it receives:
with console logs in this file:
and so the batch "0" get the first value of the array like Buffer, here the number 123....
So at this point I was puzzled.
What I have done right now to make it work is to create a small middleware that detects if the body is a buffer and replace it with the string version:
Hope that helps someone else... Would it be sensible to handle that in trpc ? I have noticed that the recommended approach is "plug and play" and it should just work ™️, so I guess this additional check could help.
Beta Was this translation helpful? Give feedback.
All reactions