trpc: DX: using `client` as the route name causes an error
Provide environment information
System:
OS: macOS 13.1
CPU: (8) x64 Apple M1
Memory: 18.31 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
Yarn: 1.22.10 - /opt/homebrew/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
Watchman: 2022.10.03.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 109.1.47.171
Chrome: 109.0.5414.119
Safari: 16.2
npmPackages:
@tanstack/react-query: ^4.20.4 => 4.24.4
@trpc/client: ^10.7.0 => 10.9.1
@trpc/next: ^10.7.0 => 10.9.1
@trpc/react-query: ^10.7.0 => 10.9.1
@trpc/server: ^10.7.0 => 10.9.1
next: ^13.1.1 => 13.1.6
react: ^18.2.0 => 18.2.0
typescript: ^4.9.4 => 4.9.5
Describe the bug
I’ve created a route and named it client but I get this error when trying to use trpc.useContext()
client collides with a built-in method, you should rename this router or procedure on your backend
I could fix the issue by renaming it to clientRoute and the problem was solved
Link to reproduction
https://stackblitz.com/github/trpc/examples-next-minimal-starter
To reproduce
Create a route and name it client, This should trigger an error as shown in the video below:
Additional information
No response
👨👧👦 Contributing
- 🙋♂️ Yes, I’d be down to file a PR fixing this bug!
Funding
- You can sponsor this specific effort via a Polar.sh pledge below
- We receive the pledge once the issue is completed & verified
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 3
- Comments: 17 (4 by maintainers)
I’m also getting this error randomly on my build server:
Does anyone have a reproduction where this error should not be showing up (you do not have actually have a procedure named something that collides with a built-in method)?
Hey, what exactly should I rename? I fixed the error with updating tRPC
I think this happened after upgrading as a result of #3693.
I think it’s worth investigating a bit more if there are non-breaking workarounds we can do to prevent this as I think it’s really bad DX