PinkiePie
Explore posts from serverstrpc doesn't work after migrating to next 15
https://github.com/trpc/trpc/issues/6341 - however it's mostly just a copy-paste of the discussion above, i don't have an isolated project where issue can be reproduced 😦
15 replies
trpc doesn't work after migrating to next 15
@Alex / KATT 🐱 it seems like i narrowed down the issue to the exact file and commit 🙂 The change was introduced in this commit/line: https://github.com/trpc/trpc/commit/87fde62978441b1cedd1d5cf7290f6ade9a92607#diff-981f2f06bfbbee188e14a4f7991f370e9042eb5c21995e24e183ab76acc5ce01R136 and then here https://github.com/trpc/trpc/commit/3df8b21beb4925cf73194fc776d1a88603a3c420#diff-981f2f06bfbbee188e14a4f7991f370e9042eb5c21995e24e183ab76acc5ce01L136
req.socket
exists locally with node, but it seems like it doesn't exist in lambdas environment (next adapter with netlify backed by aws). so, it fails on this line. In this env, request object is an instance of ComputeJsIncomingMessage
class - I don't really know if it comes from next itself, or from lambdas, it's what i've seen when i put console.log
in trpc code using yarn patch
. It looks like this issue has nothing to do with nextjs upgrade, but with the fact i didn't pin exact trpc version but used "@trpc/server": "next"
, and it was unintentionally upgraded together with nextjs. As a temporary workaround i reverted it back to a version before this change was introduced (11.0.0-rc.608), and now everything works fine15 replies
PPrisma
•Created by PinkiePie on 5/19/2024 in #help-and-questions
how to return an empty array instead of null
@Nurul (Prisma) yep, i use composite types, so I had to do the thing you proposed for every model which uses my type. it works, and it achieved the desired outcome, but it feels like a dirty workaround anyway. prisma doesn't have optional lists. Why then it returns me a
null
instead of an empty array? That's a misleading DX. Prisma should either allow optional lists in the schema, so m Int[]?
will produce number[] | null
type, and force me to check the array before accessing it, or it should return an empty array by default instead of null. Currently, the field m
can be nullable on the database level (for example if I pass it undefined
during create
operation, but the generated TS type shows like it can be never optional. So, I will have to add the check if the field m
everywhere, but the devs after me would try to remove it as "unnecessary" check (type in TS and schema clearly shows that it's a mandatory field).
So, your solution works as a temporary fix, but for sure it's something wrong on Prisma's side. Either return []
by default instead of null
, or allow us to mark lists as optional in schema, so we will generate correct TS types5 replies