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![](https://utfs.io/f/6341f0c6-396f-406a-ab3f-8984cc1cce4a-1nq2cb.png)
23 Replies
one solution to solve this was to define router type with
AnyRouter
that you export, however then I get this error in my client![](https://utfs.io/f/64c43ed2-02ca-4843-8cac-0ccc0cbd5ea4-1nq2cb.png)
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?
Yeah, it's aliased path, and everything worked before bumping up version
![](https://utfs.io/f/7706924c-d555-4b57-9e0b-ef5dc577e8b5-1nq2cb.png)
here I set transformer
and as for the router I import it in different file and add routes
![](https://utfs.io/f/d2d76ee7-9f24-4872-95f5-589a9107dd90-1nq2cb.png)
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
yeah just tried, didn't do anything :/
Yeah, I'm always reloading extension host and ts server (on vs code)
Can you try commenting out all your routes in appRouter and just adding one really trivial one?
just a hello world query
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
![](https://utfs.io/f/d6cabfc0-6b90-4c39-9415-cf5e353b82ca-1nq2cb.png)
and still get same error 😄
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?
It's locating in the same one