We're having some serious Intellisense performance issues with v10

Hello. We have about ~30ish routers in mergeRouters (we're working on changing this to a namespaced router) but we're having some serious performance issues (10s+ to open Intellisense in VSCode with extensions disabled). We've also confirmed that TypeScript gets slower the more routers we add. Obviously this is expected, but we didn't think we'd run into this issue with 100+ procedures. We thought we'd be facing an issue like this with 2,000+. Any help on this would be appreciated. We'd be happy to send over an NDA and pay for help as well. Although I can always talk through what's going on here on Discord and add some traces if you feel it would be useful. Btw this is in a monorepo configuration. I haven't yet tried isolating the package on its own and testing to see if the performance is any better. It's a very big project that powers our startup. Thanks.
Some of our routes use tRPC OpenAPI btw, have not confirmed if that's the source of the slowdown. We also tried adding type annotations to the procedures but there was little to no performance improvement. Here is a similar post that talks about exactly this: https://discord.com/channels/867764511159091230/1161320446722064385/1161320446722064385 it looks like this is a known issue and there's even a library to help with this: https://twitter.com/whizzaf/status/1683998923382304768 We're also using Zod. It looks like Zod has performance issues we were able to narrow it down. it looks like the issue is with trpc-openapi. seems like a massive bug. 200% performance degradation (from 400ms to 1200ms) just kidding, it's also Zod. both Zod and trpc-openapi completely tank our performance
Hey, yeah Zod is the root of all pain with tRPC, even trpc-openapi I believe consumes those types and in doing so would blow up the performance cost, though I'm not a use of that package personally We do a lot of type mapping, and if we're mapping over deep and expensive types, the type mapping also becomes expensive Zod produces much more complex types than you would assume I recommend avoiding all the masking+merging types in zod. Omit, Pick, Exclude, and a bunch of others. That will make a huge difference You can achieve the same as those much more cheaply by composing your zod objects from plain JS objects containing named zod types, which might get you back to just bearable levels. I'm fighting the same thing at work and honestly the solution for us is using less Zod
i'm thinking about just switching us to Typebox. have you tried other validation libraries?
We support quite a few! So definitely worth a shot Unfortunately not a lot of good tooling for DX performance out there right now so it's hard to make a recommendation, but I'm pretty keen on some codegen approaches which essentially use normal TS types - you can't get more efficient than that
to anyone who is seeing this in the future, enable disableSourceOfProjectReferenceRedirect and call it a day. you'll lose out on direct project references but at least now you'll be able to do your development because intellisense and autocomplete work
I’ll try this on my work codebase and if it works might lead us to some future improvements

Looking for more? Join the community!

Recommended Posts
Parsing FormData on trpcHi all, I have function to put object on S3 const putObjectToS3 = async (body: FormData) => { ... }TRPC to connect a client app with a backend apigateway ?Hi everyone! Is it a good practice to use TRPC to connect my client application (Next.Js) with my bWebsocket server implementations with TRPC createWSClientIs anyone aware of a websocket server that is compatible with trpc websocket client that isn't usingAdvanced Permissioning In MiddlewareI need to handle somewhat complicated permissioning logic, for example: `User A can read (but not How is the Client Generated with just the typesI'm trying to build a trpc like app for building restful apis with sveltekit. In trpc sveltekit onlyGenerate iOS Swift tRPC clientHey all, I'm looking to get pointed in the right direction for how to best generate a native tRPC cMiddleware that returns data instead of throwing errorIs there any way for a middleware to return typed data instead of throwing an error? I can only see Including multi-tenant config into tRPC contextHey all, I've been working on upgrading my app to support multi-tenancy, inspired by Vercel's PlatfSuggestion to deal with external dependencies on backend side?Hello, i have a question about dealing with external dependencies inside mutations and queries on tTRPC & Zod LoggingI'm building a backend and if my input validation fails I want to log the failure but couldn't figurHow to handle Query Errors on client side (show toast on 401)Hey ! Hope you're doing well ! I wanted to know if someone can explain to me how to handle errors onTRPCClientError: JSON Parse error: Single quotes (') are not allowed in JSONI am getting this error when deployed but not when running locally. ```json TRPCClientError: JSON PHow to access isLoading if a Query is inside a componentI am having trouble in accessing isLoading from a query, the problem is that the Query is placed instRPC and vite serverless, are there any exmaples?Now that tanstack router is out I would want to move out of nextjs, but keep the convenience of hostHow can i use inferprocedureoutput?I'd like to write this code type-safely:```ts const handleQuery = (query: /* ? */) => {} const MyCoCan a URL be formatted with dashes, such as "user-list" in the context of trpc?Can a URL be formatted with dashes, such as "user-list" in the context of trpc? ``` const appRouter Incorrect type inference with discriminated unions.Hey folks, I am having a really weird issue. Here is a minimal reproducible example: **https://tsplGet Query Key on ServerI'm following some recommended practices from one of the react query maintainers `@tkdodo` and want ReferenceError: Cannot access 'appRouter' before initializationHi friends im having trouble implementing a "protected" or "private" procedure in TRPC using Next.jstrpc openapi does not work on app routerhttps://github.com/jlalmes/trpc-openapi Can i just know if trpc open api for next is also applicable