Kimblis
Kimblis2y ago

Issue with monorepo architecture ant tRPC

Hi, we had an issue with batched requests that if we batch some requests they produce a TRPCClientError which says Cannot read properties of undefined (reading 'messsage') so I have read that at least error problem was fixed in newer versions, so we tried to update version, but then the builds started to fail. We get this error (photos in the thread) and more information
23 Replies
Kimblis
Kimblis2y ago
one solution to solve this was to define router type with AnyRouter that you export, however then I get this error in my client
Kimblis
Kimblis2y ago
Nick
Nick2y ago
Could you share where you’re setting up your transformer on the API? I would focus on fixing the backend errors first, the frontend might give useless errors until the backend itself is compiling ok Putting a # in your import names is something I haven’t seen before though, is that a valid import character?
Kimblis
Kimblis2y ago
Yeah, it's aliased path, and everything worked before bumping up version
Kimblis
Kimblis2y ago
Kimblis
Kimblis2y ago
here I set transformer and as for the router I import it in different file and add routes
Kimblis
Kimblis2y ago
Nick
Nick2y ago
Does your tsconfig for the API have allowSyntheticDefaultImports enabled? Might not affect here, but it's solved many weird issues with default imports for me Also consider reloading your typescript language server (or just window) each time you tweak something, it can just be your editor being broken
Kimblis
Kimblis2y ago
yeah just tried, didn't do anything :/ Yeah, I'm always reloading extension host and ts server (on vs code)
Nick
Nick2y ago
Can you try commenting out all your routes in appRouter and just adding one really trivial one? just a hello world query
Kimblis
Kimblis2y ago
and it is weird that one error is mad on superjson since versions between services are literally the same (checked even node_modules), and as for the AnyRoute maybe the type isn't that decent? 😄 Any way to describe router type differently? damn, tried this
Kimblis
Kimblis2y ago
Kimblis
Kimblis2y ago
and still get same error 😄
Nick
Nick2y ago
Is TS locating superjson in a different monorepo package than it's being imported from? Are you sure it's actually installed in the package it's being imported into?
Kimblis
Kimblis2y ago
It's locating in the same one