\n\n\n\n### Link to reproduction\n\nNot Needed\n\n### To reproduce\n\nfetch an query on the server and the error type is messed up\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3171],{"name":3172,"color":3173},"🐛 bug: unconfirmed","e99695",6956,"trpc","open","bug: since TRPC v11.5.0 errors on createTRPCOptionsProxy are broken and not typed properly","2025-09-22T23:38:43Z","https://github.com/trpc/trpc/issues/6956",0.6781136,{"description":3182,"labels":3183,"number":3185,"owner":3175,"repository":3175,"state":3176,"title":3186,"updated_at":3187,"url":3188,"score":3189},"### Provide environment information\n\n```\r\n System:\r\n OS: macOS 14.4.1\r\n CPU: (8) arm64 Apple M1\r\n Memory: 62.41 MB / 16.00 GB\r\n Shell: 5.9 - /bin/zsh\r\n Binaries:\r\n Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node\r\n npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm\r\n pnpm: 9.12.2 - ~/.nvm/versions/node/v20.10.0/bin/pnpm\r\n Browsers:\r\n Chrome: 130.0.6723.92\r\n Safari: 17.4.1\r\n npmPackages:\r\n @tanstack/react-query: ^5.59.19 => 5.59.19 \r\n @trpc/client: 11.0.0-rc.608 => 11.0.0-rc.608+f75de97b3 \r\n @trpc/react-query: 11.0.0-rc.608 => 11.0.0-rc.608+f75de97b3 \r\n react: ^18.3.1 => 18.3.1 \r\n typescript: ^5.6.3 => 5.6.3 \r\n```\n\n### Describe the bug\n\nI have a query which I just want to run in a certain condition (if another query had a non-empty result). I was trying to follow the docs (see https://trpc.io/docs/client/react/useQueries in conjunction with https://tanstack.com/query/v4/docs/framework/react/guides/dependent-queries#usequeries-dependent-query) but I could not get my code snippet to compile.\n\n### Link to reproduction\n\nhttps://stackblitz.com/edit/github-qa2kdy?file=src%2Fpages%2Findex.tsx\n\n### To reproduce\n\nChange the text in the variable `text` in line 10 of the `index.tsx`, and you'll see the error appear. To me the error only appeared after changing the text.\n\n### Additional information\n\nHere's the typescript error I get on the callback:\r\n\r\n```\r\nArgument of type '(t: UseQueriesProcedureRecord\u003C{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }, { greeting: QueryProcedure\u003C{ input: { name?: string | null | undefined; }; output: { text: string; }; }>; }>) => [] | [...]' is not assignable to parameter of type '(t: UseQueriesProcedureRecord\u003C{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }, { greeting: QueryProcedure\u003C{ input: { name?: string | null | undefined; }; output: { text: string; }; }>; }>) => readonly []'.\r\n Type '[] | [TrpcQueryOptionsForUseQueries\u003C{ text: string; }, { text: string; }, TRPCClientError\u003C{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }>>]' is not assignable to type 'readonly []'.\r\n Type '[TrpcQueryOptionsForUseQueries\u003C{ text: string; }, { text: string; }, TRPCClientError\u003C{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }>>]' is not assignable to type 'readonly []'.\r\n Source has 1 element(s) but target allows only 0.(2345)\r\n```\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3184],{"name":3172,"color":3173},6188,"bug: React: Types for callback of `trpc.useQueries` doesn't allow returning an empty array","2025-03-20T15:42:41Z","https://github.com/trpc/trpc/issues/6188",0.68788016,{"description":3191,"labels":3192,"number":3196,"owner":3175,"repository":3175,"state":3176,"title":3197,"updated_at":3198,"url":3199,"score":3200},"### Describe the feature you'd like to request\n\nI wanna set a default global callback in trpc.\r\n\r\nFor example, i can has a default error alert tip if we throw error in request, or we have take mutation show operate success alert tip.\r\n\r\nNow, i have to set those in every where.\r\n\r\nI take a look of source code, its weird:\r\n\r\n- why only get default option with `getMutationDefaults` rather than `getDefaultOptions`?\r\n- why not append default option into `__useMutation` options?\r\n- in `mutationSuccessOverride`, why the `overrides` handler is higher priority than options callback in caller where define as `originalFn`?\r\n\r\nhttps://github.com/trpc/trpc/blob/42e6910cfb9f25ab12f522a3ede01a0078b5bc6d/packages/react-query/src/shared/hooks/createHooksInternal.tsx#L338-L370\n\n### Describe the solution you'd like to see\n\nSet in `trpc.createTRPCReact` \r\n```ts\r\nexport const trpc = createTRPCReact\u003CAppRouter>({\r\n overrides: {\r\n useMutation: {\r\n onSuccess: ()=> console.log('success'),\r\n },\r\n },\r\n});\r\n``` \r\n\r\nor in `new QueryClient` \r\n\r\n```ts\r\nexport const queryClient = new QueryClient({\r\n defaultOptions: {\r\n mutations: {\r\n onSuccess: () => console.log('success'),\r\n onError: () => console.log('error'),\r\n },\r\n },\r\n});\r\n```\n\n### Describe alternate solutions\n\nnone\n\n### Additional information\n\nI want to contribute code to implement this feature, but i cant understand why there logic is it.\r\n\r\nI'm not sure if this is intentional, can you give me some context?\n\n### 👨👧👦 Contributing\n\n- [X] 🙋♂️ Yes, I'd be down to file a PR implementing this feature!",[3193],{"name":3194,"color":3195},"✅ accepted-PRs-welcome","0052cc",4924,"feat: wanna default handle callback for `useMutation` in `react-query`","2025-03-20T15:41:58Z","https://github.com/trpc/trpc/issues/4924",0.69021237,{"description":3202,"labels":3203,"number":3204,"owner":3175,"repository":3205,"state":3176,"title":3206,"updated_at":3207,"url":3208,"score":3209},"heres' an example: \r\n\r\n\u003Cimg width=\"726\" alt=\"image\" src=\"https://github.com/jlalmes/trpc-openapi/assets/4019054/3ff97ec5-7533-4327-9cab-ef683b66390c\">\r\n\r\nif I have this code defining a schema and try to make TRPC calls (on ANY API, not just this one), I'll get this error: \r\n\r\n```\r\nerror - TRPCError: [query.question.read] - Input parser key: \"labels\" must be ZodString, ZodNumber, ZodBoolean, ZodBigInt or ZodDate\r\n at /Users/david/Projects/WORK/DFDF/DDQ360/node_modules/trpc-openapi/dist/generator/schema.js:72:27\r\n at Array.map (\u003Canonymous>)\r\n at getParameterObjects (/Users/david/Projects/WORK/DFDF/DDQ360/node_modules/trpc-openapi/dist/generator/schema.js:65:10)\r\n at /Users/david/Projects/WORK/DFDF/DDQ360/node_modules/trpc-openapi/dist/generator/paths.js:61:66\r\n at forEachOpenApiProcedure (/Users/david/Projects/WORK/DFDF/DDQ360/node_modules/trpc-openapi/dist/utils/procedure.js:34:13)\r\n at getOpenApiPathsObject (/Users/david/Projects/WORK/DFDF/DDQ360/node_modules/trpc-openapi/dist/generator/paths.js:13:45)\r\n at generateOpenApiDocument (/Users/david/Projects/WORK/DFDF/DDQ360/node_modules/trpc-openapi/dist/generator/index.js:27:50)\r\n at eval (webpack-internal:///(api)/./src/server/api/root.ts:51:98)\r\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {\r\n code: 'INTERNAL_SERVER_ERROR',\r\n [cause]: undefined\r\n}\r\n```\r\n\r\n",[],391,"trpc-openapi","zod array objects break this","2024-08-30T17:17:14Z","https://github.com/trpc/trpc-openapi/issues/391",0.6934536,{"description":3211,"labels":3212,"number":3213,"owner":3175,"repository":3175,"state":3214,"title":3215,"updated_at":3216,"url":3217,"score":3218},"I have a mutation that changes data in the extern system (for example `posts`).\r\n\r\nFrom my UI I public post on `external-api`\r\nand fetch this api for refresh posts after this mutation\r\n\r\nI want save changes that make my system in `extenal-api`, but it is not very important, more important is to update `posts` on my site immediately after addiction newPost, without awaiting save these posts in my database\r\n\r\nI expected that this code makes it\r\n```\r\n .mutation('post.add', {\r\n input: z.object({ title: z.string(), text: z.string() }),\r\n async resolve({ input }) {\r\n const postId = await useExternApiForPublicThisPost(input);\r\n \r\n // save change in my database, but not await response\r\n prisma.posts.create({\r\n data: {postId, ...input}\r\n });\r\n }\r\n })\r\n```\r\n\r\nbut unfortunately, after resolving this request, tRPC kill Prisma, for save data in the database need await Prisma, but it's is slow\r\n\r\nHow can return response from tRPC, but continue to execute remaining promises?",[],1473,"closed","tRPC (on nextjs) kill not awaited promises","2022-01-30T20:12:20Z","https://github.com/trpc/trpc/issues/1473",0.65368026,{"description":3220,"labels":3221,"number":3225,"owner":3175,"repository":3175,"state":3214,"title":3226,"updated_at":3227,"url":3228,"score":3229},"`@trpc/server`: 7.0.0\r\nTypescript tested: 4.2.4 & 4.3.2\r\n\r\nThere is a small, but annoying quirk with inference on the `ProcedureInputParserCustomValidatorEsque\u003CTInput>`:\r\n\r\n```ts\r\nrouter()\r\n .mutation(\"write\", {\r\n // 1. \"a\" parameter is inferred as unknown (=correct), but the return type is not inferred up the type tree\r\n input: (a) => \"x\",\r\n // 2. you need to explicitly type (a: unknown), for the inference of return type go up the tree:\r\n // input: (a: unknown) => \"x\"\r\n resolve({input}) {\r\n // input is resolved as unknown in case 1. and correctly as \"string\" in 2. case\r\n }\r\n })\r\n```",[3222],{"name":3223,"color":3224},"wontfix","ffffff",511,"@trpc/server - Inferrence quirk with ProcedureInputParserCustomValidatorEsque\u003CTInput>","2022-10-05T00:09:35Z","https://github.com/trpc/trpc/issues/511",0.6636503,{"description":3231,"labels":3232,"number":3236,"owner":3175,"repository":3175,"state":3214,"title":3237,"updated_at":3238,"url":3239,"score":3240},"### Provide environment information\n\n```\r\nSystem:\r\n OS: Windows 10 10.0.19044\r\n CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz \r\n Memory: 16.64 GB / 31.95 GB\r\n Binaries:\r\n Node: 16.17.0 - C:\\Program Files\\nodejs\\node.EXE\r\n Yarn: 1.22.19 - C:\\Program Files\\nodejs\\yarn.CMD\r\n npm: 8.15.0 - C:\\Program Files\\nodejs\\npm.CMD\r\n Browsers:\r\n Edge: Spartan (44.19041.1266.0), Chromium (104.0.1293.70) \r\n Internet Explorer: 11.0.19041.1566\r\n npmPackages:\r\n @trpc/client: ^10.0.0-proxy-alpha.57 => 10.0.0-proxy-alpha.57 \r\n @trpc/server: ^10.0.0-proxy-alpha.57 => 10.0.0-proxy-alpha.57\r\n```\n\n### Describe the bug\n\n[internals/TRPCClient.ts:281](https://github.com/trpc/trpc/blob/next/packages/client/src/internals/TRPCClient.ts#L281) handles the result message and calls `onData()` with just the data, but type defs in [createTRPCClientProxy.ts:42](https://github.com/trpc/trpc/blob/next/packages/client/src/createTRPCClientProxy.ts#L42) wrap it in `TRPCResultMessage`.\r\n\r\nIn the example below `val` is typed as `TRPCResultMessage\u003C{randomNumber: number;}>` and on autocomplete has `.id?`, `.result` and `.jsonrpc?` (all of which are actually undefined) but outputs `{ randomNumber: 0.864038269589827 }` into console and `val.randomNumber` is marked as non-existent in VS Code but works\n\n### To reproduce\n\nCreate any router with a subscription like in https://trpc.io/docs/v10/subscriptions , for example:\r\n```ts\r\nexport const appRouter = t.router({\r\n randomNumber: t.procedure.subscription(() => {\r\n return observable\u003C{ randomNumber: number }>((emit) => {\r\n const timer = setInterval(() => {\r\n emit.next({ randomNumber: Math.random() });\r\n }, 1000);\r\n return () => {\r\n clearInterval(timer);\r\n };\r\n });\r\n }),\r\n});\r\n```\r\nclient:\r\n```ts\r\nproxy.randomNumber.subscribe(null, {\r\n onData(val) {\r\n console.log(val);\r\n },\r\n});\r\n```\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3233],{"name":3234,"color":3235},"🐛 bug","d73a4a",2576,"[v10] bug: Subscriptions' return type in onData shouldn't be wrapped in TRPCResultMessage","2022-10-04T00:18:09Z","https://github.com/trpc/trpc/issues/2576",0.66896224,{"description":3242,"labels":3243,"number":3248,"owner":3175,"repository":3175,"state":3214,"title":3249,"updated_at":3250,"url":3251,"score":3252},"### Provide environment information\r\n\r\n```\r\n System:\r\n OS: macOS 12.5\r\n CPU: (8) arm64 Apple M1\r\n Memory: 74.78 MB / 16.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 18.5.0 - ~/.nvm/versions/node/v18.5.0/bin/node\r\n Yarn: 1.22.17 - ~/.yarn/bin/yarn\r\n npm: 8.12.1 - ~/.nvm/versions/node/v18.5.0/bin/npm\r\n Browsers:\r\n Chrome: 104.0.5112.101\r\n Chrome Canary: 107.0.5257.0\r\n Firefox Developer Edition: 104.0\r\n Safari: 15.6\r\n npmPackages:\r\n @trpc/client: 10.0.0-alpha.50 => 10.0.0-alpha.50 \r\n @trpc/server: 10.0.0-alpha.50 => 10.0.0-alpha.50 \r\n```\r\n\r\n### Describe the bug\r\n\r\n```js\r\nasync function normalLookingFunction() {\r\n return createTRPCProxyClient(anything)\r\n}\r\n\r\n// Throws `client[procedureType] is not a function` (path = `\"then\"`)\r\nnormalLookingFunction().then(client => console.log(client))\r\n```\r\n\r\n\r\n### To reproduce\r\n\r\nSee above\r\n\r\n### Additional information\r\n\r\nI understand there's some reason behind switching to `[operation].(mutate|query)` ordering, but I'm not exactly sure how to address this kind of issue where the user might have a `then` operation.\r\n\r\nThis was absolute hell to figure out what changed to cause this until I broke out the debugger, because the proxy truncates the stacktrace inside native promise resolution logic. 😞 \r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [x] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3244,3245],{"name":3234,"color":3235},{"name":3246,"color":3247},"👋 free for all","289B36",2521,"[v10] bug: v10 Promise resolving to return of `createTRPCProxyClient` throws `client[procedureType] is not a function` (path = `\"then\"`)","2022-10-06T18:03:34Z","https://github.com/trpc/trpc/issues/2521",0.6711581,{"description":3254,"labels":3255,"number":3260,"owner":3175,"repository":3175,"state":3214,"title":3261,"updated_at":3262,"url":3263,"score":3264},"This is a super weird one. It may have been me who broke it, and I haven't been able to figure out how/why yet. My team's project hits this error trying to update to v9.6.0 (from v9.0.0-alpha.0, which was before #915 went in but after/somewhere in the middle of #718).\r\n\r\nWe're finding that *under certain conditions* `inferProcedureInput\u003C>` is returning `unknown` (in fact, it's the type inference of router definition - the procedure itself is `Procedure\u003CContext, Context, unknown, { ...result... }>`). Repro (note - this does _not_ repro in this repo, if you do `import * as trpc from '../src'` in a test, which is what I tried first. You can use this [playground link](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgUwB5mQYxgFQJ4YDyAZnAL5zFQQhwDkaG2AtDAcnQNwBQokscAFRwAhgGc4MKGEyVqtOgAEpMgPRjkUAG6a6vcNHgIAXhSo16xiABM93TBAB2Y+CLBgAShACuMTXABeSWlMADpqX00ACgBKUJBNAHNkKO44ehFrEGBHVToAGjTgmSL08J8-KFjSuHjfERhgJyi6PxcAWXrGpwLEGvScsF8ALjhjUIgAIwArLBgohH70yggIUfGXKBzE2MLl5bIYvf24KGQxCAAbHVHxPEdZBbhB33IYwIA+OAADABIEF4wULEVZkACE32O6UONXiwGs1kuyAA7iIzlE7g84E9HGh4IdPnBcah5jEjtwYjxuGwMHBOjAGk1nIFJOwIKQ3J4KppQgB9azIYh1BndZw8RhzfBEYgAHiKKjCOWImgACtRMMhrN4zgBJRxDGAy+mMpxiADadEy2VybRgxtFdAAuh9uB9YqEYBAAKIAR28IkuUuQJBlSBBazgm225DdlO4EuwQZD8pCoSVqvVmu1yD1BqNXSZ5stWRyqlt9qZTpdsdCjggQM9ACFkABVRwAazryMcsR4QA) to see it going wrong:\r\n\r\n```ts\r\nimport { expectTypeOf } from 'expect-type';\r\nimport * as trpc from '@trpc/server'\r\nimport {z} from 'zod'\r\n\r\nconst appRouter = trpc.router().merge(\r\n 'admin/',\r\n trpc\r\n .router()\r\n .mutation('testMutation', {\r\n input: z.object({\r\n foo: z.string(),\r\n }),\r\n resolve: async ({ input }) => `${input.foo}!`,\r\n })\r\n .middleware(async ({ next }) => next()),\r\n);\r\n\r\ntype Mutations = typeof appRouter._def.mutations;\r\n\r\nexpectTypeOf\u003C\r\n trpc.inferProcedureInput\u003CMutations['admin/testMutation']>\r\n>().toEqualTypeOf\u003C{ foo: string }>();\r\n\r\nexpectTypeOf\u003C\r\n trpc.inferProcedureInput\u003CMutations['admin/testMutation']>\r\n>().not.toBeUnknown();\r\n```\r\n\r\nThe two `expectTypeOf` tests fail. The second is just to show that the inferred type is `unknown` and that it isn't a typo/bad test setup.\r\n\r\nUpdate: The tests succeed if you remove the `.middleware(async ({ next }) => next())` line (in this case, the middleware is pointless - we are seeing it for a similar middleware that throws under certain circumstances)\r\n\r\nUpdate 2: It can also be repro'd by doing `import * as trpc from '../dist/trpc-server.cjs'` in this repo, which makes things much easier. Could there be some types that are being stripped at build time, maybe?",[3256,3257],{"name":3234,"color":3235},{"name":3258,"color":3259},"🧙🏻 typescript wizardry","391441",949,"`inferProcedureInput` broken in published package","2022-10-04T18:08:21Z","https://github.com/trpc/trpc/issues/949",0.6720254,{"description":3266,"labels":3267,"number":3268,"owner":3175,"repository":3175,"state":3214,"title":3269,"updated_at":3270,"url":3271,"score":3272},"### Describe the feature you'd like to request\r\n\r\nMany upstream APIs (e.g. OpenAI's GPT) stream responses to the client. It would be great if TRPC supported such streaming requests.\r\n\r\n### Describe the solution you'd like to see\r\n\r\nI'd imagine this would look like a mutation or query where the resolver is an async generator. Example:\r\n\r\n```typescript\r\npublicProcedure\r\n .streamingMutation(async function* ({ input, ctx }) {\r\n for(let x=0x;\u003C10;x++) {\r\n yield x;\r\n await sleep(100);\r\n }\r\n });\r\n```\r\n\r\n### Describe alternate solutions\r\n\r\nAn alternative is to set up subscriptions and map the mutation inputs to some identifier in the subscription. The problem with this approach is (a) it depends on websockets, which are difficult to support from an infrastructure perspective, (b) the race conditions between establishing a socket connection and corresponding this with mutations/queries can be miserable.\r\n\r\n### Additional information\r\n\r\nI'd mostly like to understand any suggestions for how to approach this and whether you'd support a PR. Creating a `streamingMutation` procedure type, for instance, is fairly invasive but may be the correct approach.\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [X] 🙋♂️ Yes, I'd be down to file a PR implementing this feature!\r\n\r\n\r\n\n```[tasklist]\n### Tasks\n```",[],4477,"feat: Streaming Mutations / Queries","2025-03-20T15:41:42Z","https://github.com/trpc/trpc/issues/4477",0.67240655,["Reactive",3274],{},["Set"],["ShallowReactive",3277],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fDo8jvHkPQBydA8bizfTziDj2uEqEs7auuEG0rrRB4nk":-1},"/trpc/trpc/527"]