ToP
Cannot set headers after they are sent to the client
I tried to narrow it down. It seems to be problem with createContext. Even if i change it to this very simple implementation, it returns same error.
It seem like, that I can set cookies in createContext like this:
But if I return method from
createContext
(first example), or even if I return res
and then call res.appendHeader(...)
in my route, it always return this error 🤔 Seems like res
in mutable only in createContext
but not in routes (authRouter.login
etc.)7 replies
`The property 'query' in your router collides with a built-in method`
Yeah. Maybe it might be good idea to have working example of tsconfig in docs? And maybe even collection of keys you cant use in your tsconfig? It might help some people in future.
19 replies
`The property 'query' in your router collides with a built-in method`
I have solution. In my case, it was caused by defining type of router, instead of letting it be infered.
So instead of:
const router: ReturnType<typeof router> = router({...})
I did this:
const router = router({...})
The reason why I added type to router in first place was because, it was giving me this error
The inferred type of 'router' references an inaccessible 'this' type. A type annotation is necessary.
But that was caused by tsconfig.json
I needed to remove "declaration": true
Now everything works perfectly19 replies
`The property 'query' in your router collides with a built-in method`
I have exactly same issue. I tried to narrow it down, by reverting to most basic setup of trpc from Quickstart. Only difference is that I am using turborepo.
At first I didnt even had types (everything was any), when i imported from trpc package from turborepo to client app. But then i used Subpath imports and now vscode shows correct types. But then, when i create tRPC client it has this string type instead of something useful:
"The property 'query' in your router collides with a built-in method, rename this router or procedure on your backend." | "The property 'mutation' in your router collides with a built-in method, rename this router or procedure on your backend." | ... 5 more ... | "The property 'runtime' in your router collides with a built-in method, rename this router or procedure on your backend."
Only thing that helped was moving server to same package as the app. Effectively canceling monorepo 😀 I think that problem is that in turborepo, I cant really import AppRouter type with relative path, because it is import between turborepo packages, and they do some magic with paths which breaks trpc types probably :/
It is only type/intellisense issue, everything else works. But I would say that typesafety and intellisense is kinda main reason why people love tRPC.
I dont expect that anybody would be able to help me with this, but if somebody could maybe explain what this error means and why it can occur, that would help me greatly
19 replies