\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.6346551,{"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```\nSystem:\n OS: macOS 15.5\n CPU: (12) arm64 Apple M4 Pro\n Memory: 547.69 MB / 24.00 GB\n Shell: 5.9 - /opt/homebrew/bin/zsh\n Binaries:\n Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node\n Yarn: 1.22.22 - /opt/homebrew/bin/yarn\n npm: 10.9.2 - ~/.nvm/versions/node/v22.13.1/bin/npm\n pnpm: 10.12.1 - ~/.nvm/versions/node/v22.13.1/bin/pnpm\n bun: 1.2.18 - ~/.bun/bin/bun\n Watchman: 2025.07.28.00 - /opt/homebrew/bin/watchman\n Browsers:\n Chrome: 139.0.7258.127\n Safari: 18.5\n npmPackages:\n @tanstack/react-query: ^4.40.0 => 4.40.0\n @trpc/client: ^10.45.2 => 10.45.2\n @trpc/react-query: ^10.45.2 => 10.45.2\n @trpc/server: ^10.45.2 => 10.45.2\n react: ^18.3.1 => 18.3.1\n typescript: ~5.8.3 => 5.8.3\n```\n\n### Describe the bug\n\n`TRPCClientError: ReadableStream uploading is not supported`\n\nGetting this error in a few `.mutate` or `mutate/mutateAsync` calls using `useMutations` in safari. It works perfectly well in Chrome and Firebox based browsers.\n\nI initially thought it might be due to batching and changed `httpBatchLink` to `httpLink`, also tried to use `splitLink` while checking for Safari but getting the same issue. It also doesn't fail for all mutations but only some.\n\n### Link to reproduction\n\nN/A\n\n### To reproduce\n\nN/A\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!",[3184],{"name":3172,"color":3173},6895,"bug: ReadableStream uploading is not supported on safari","2025-08-18T12:53:19Z","https://github.com/trpc/trpc/issues/6895",0.6636929,{"description":3191,"labels":3192,"number":3196,"owner":3175,"repository":3175,"state":3197,"title":3198,"updated_at":3199,"url":3200,"score":3201},"### Provide environment information\n\n```\r\n System:\r\n OS: macOS 13.5.2\r\n CPU: (10) arm64 Apple M1 Max\r\n Memory: 7.06 GB / 64.00 GB\r\n Shell: 5.9 - /bin/zsh\r\n Binaries:\r\n Node: 20.5.1 - ~/Library/Caches/fnm_multishells/26427_1696576131210/bin/node\r\n Yarn: 1.22.19 - /opt/homebrew/bin/yarn\r\n npm: 9.8.0 - ~/Library/Caches/fnm_multishells/26427_1696576131210/bin/npm\r\n Browsers:\r\n Chrome: 117.0.5938.149\r\n Safari: 16.6\r\n npmPackages:\r\n @trpc/client: 10.38.5 => 10.38.5 \r\n @trpc/server: 10.38.5 => 10.38.5 \r\n typescript: 5.1.6 => 5.1.6\r\n```\n\n### Describe the bug\n\nWhen using the tRPC Express adapter and specifying the `maxBodySize` parameter, the `PAYLOAD_TOO_LARGE` error is actually not propagated to the client. Instead, the `fetch` promise rejects without a response and TRPCClient reports `Error: TRPCClientError: Unexpected end of JSON input`\r\n\r\nI added the following log to the tRPC module `nodeHTTPRequestHandler`:\r\n\r\n```\r\n opts.req.on('error', err => {\r\n console.log('Request error', opts.path, err)\r\n })\r\n```\r\n\r\nAnd this error callback gets called with an Aborted error (`ECONNRESET`). What seems to happen is that the request stream is closed before the headers or the response body can be sent back to the client.\r\n\r\nThis line in `getPostBody` explicitly destroys the underlying request TCP socket when the `maxBodySize` is exceeded:\r\n\r\nhttps://github.com/trpc/trpc/blob/3f6f3b73d9720b92aab5f0d72d61c874e6a4772b/packages/server/src/adapters/node-http/content-type/json/getPostBody.ts#L31\r\n\r\nCommenting out `// req.socket.destroy()` fixes the issue and the `PAYLOAD_TOO_LARGE` error is properly propagated to the client.\r\n\r\nI'm unsure why `req.socket.destroy()` is explicitly called, but there's probably a reason?\n\n### Link to reproduction\n\nhttps://github.com/jussisaurio/trpc-body-size-repro\n\n### To reproduce\n\n1. Create a tRPC server with `maxBodySize` and set it to a low value that you can easily exceed with a manual test\r\n2. Call the endpoint with a payload exceeding `maxBodySize`\r\n\r\nExpected: PAYLOAD_TOO_LARGE error\r\nActual: Unexpected end of JSON input\n\n### Additional information\n\nWilling to file a PR as soon as I understand why `req.socket.destroy()` is called in the first place\n\n### 👨👧👦 Contributing\n\n- [X] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3193],{"name":3194,"color":3195},"🐛 bug","d73a4a",4886,"closed","bug: PAYLOAD_TOO_LARGE error is never returned to client when body size exceeds maxBodySize","2025-03-20T15:41:57Z","https://github.com/trpc/trpc/issues/4886",0.5965267,{"description":3203,"labels":3204,"number":3209,"owner":3175,"repository":3175,"state":3197,"title":3210,"updated_at":3211,"url":3212,"score":3213},"### Provide environment information\n\napi client:\n\n```\n System:\n OS: macOS 15.5\n CPU: (8) arm64 Apple M3\n Memory: 127.13 MB / 16.00 GB\n Shell: 5.9 - /bin/zsh\n Binaries:\n Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node\n Yarn: 1.22.22 - /opt/homebrew/bin/yarn\n npm: 10.9.3 - ~/.nvm/versions/node/v22.18.0/bin/npm\n pnpm: 10.10.0 - ~/Library/pnpm/pnpm\n Watchman: 2025.06.23.00 - /opt/homebrew/bin/watchman\n Browsers:\n Chrome: 139.0.7258.128\n Safari: 18.5\n npmPackages:\n @trpc/client: 11.4.4 => 11.4.4\n @trpc/server: 11.4.4 => 11.4.4\n typescript: ^5.0.0 => 5.8.3\n```\n\napi:\n\n```\n System:\n OS: macOS 15.5\n CPU: (8) arm64 Apple M3\n Memory: 111.27 MB / 16.00 GB\n Shell: 5.9 - /bin/zsh\n Binaries:\n Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node\n Yarn: 1.22.22 - /opt/homebrew/bin/yarn\n npm: 10.9.3 - ~/.nvm/versions/node/v22.18.0/bin/npm\n pnpm: 10.10.0 - ~/Library/pnpm/pnpm\n Watchman: 2025.06.23.00 - /opt/homebrew/bin/watchman\n Browsers:\n Chrome: 139.0.7258.128\n Safari: 18.5\n npmPackages:\n @trpc/server: ^11.4.2 => 11.4.4\n typescript: ^5.0.0 => 5.8.3\n\n```\n\nbackend:\n```\n\n System:\n OS: macOS 15.5\n CPU: (8) arm64 Apple M3\n Memory: 103.20 MB / 16.00 GB\n Shell: 5.9 - /bin/zsh\n Binaries:\n Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node\n Yarn: 1.22.22 - /opt/homebrew/bin/yarn\n npm: 10.9.3 - ~/.nvm/versions/node/v22.18.0/bin/npm\n pnpm: 10.10.0 - ~/Library/pnpm/pnpm\n Watchman: 2025.06.23.00 - /opt/homebrew/bin/watchman\n Browsers:\n Chrome: 139.0.7258.128\n Safari: 18.5\n npmPackages:\n @trpc/server: ^11.4.4 => 11.4.4\n typescript: ^5.8.3 => 5.8.3\n\n```\n\n### Describe the bug\n\n## Setup\n\n- tRPC backend with a streaming endpoint (mutation procedure with an async iterator) and zod validation (v4.0.17)\n- backend is hosted via express (`@trpc/server/adapters/express`), and hosting it with hono resulted in the same issue\n- tRPC client uses `httpBatchStreamlink` to make requests to said endpoint within in a node.js runtime environment\n- the client makes requests with \"large payloads\" (e.g 2mb)\n\n### Client setup\n```ts\nexport function createNodeApiClient(\n options: TRPCClientOptions = {},\n): TRPCClient\u003CAppRouter> {\n const { baseUrl = process.env.API_URL, headers = {} } = options;\n\n return createTRPCProxyClient\u003CAppRouter>({\n links: [\n httpBatchStreamLink({\n maxItems: 1,\n url: `${baseUrl}/trpc`,\n headers: () => ({\n 'Content-Type': 'application/json',\n ...headers,\n }),\n transformer: superjson,\n }),\n ],\n });\n}\n```\n\n### The Issue\nOn _some_ requests, the response stream is aborted prematurely, even before the procedure code starts to execute (also mutations that return immediately fail with the same error, before execution). Weirdly, a request with the **exact same payload and the exact same setup** would **sometimes abort and sometimes succeed.** \n\n**On aborted requests**, the server would respond with a **\"Connection: close\"** header and only include the first line of the response: \n\u003Cimg width=\"459\" height=\"317\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/33787f80-201c-4956-adac-00e1498f8c64\" />\n\n**Whereas for successful requests** the response includes **\"Connection: keep-alive\"** and it will receive the full stream content:\n\u003Cimg width=\"561\" height=\"277\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/701b1136-38dd-4fec-9e92-3ed2086099f9\" />\n\n### Exception stack trace\n```\nsystem\nchained-exception\nexception\nstack-trace\nframe\nmodulenode:_http_server\nfunctionabortIncoming\nframe\nmodulenode:_http_server\nfunctionsocketOnClose\n\nshow 1 similar\nframe\nmodulenode:net\nframe\nmoduleasync_hooks\nfunction (trimmed javascript function)callbackTrampoline\ntypeError\nexception\nstack-trace\nframe\nmodule@trpc.server.dist:resolveResponse-9SiPu2EM\ncontext-linethrow new require_tracked.TRPCError({\nframe\nmoduletask_queues\nfunction (trimmed javascript function)processTicksAndRejections\nframe\nmodule@trpc.server.dist:resolveResponse-9SiPu2EM\nfunction (trimmed javascript function)read\ncontext-linevalue = await promise;\nframe\nmodule@trpc.server.dist:resolveResponse-9SiPu2EM\nfunctiongetRawInput\ncontext-lineconst inputs = await getInputs.read();\nframe\nmodule@sentry.core.build.esm:trpc\ncontext-lineconst rawRes = await getRawInput();\nframe\nmodule@trpc.server.dist:initTRPC-XuvQcOiC\nfunctioncallRecursive\nframe\nmoduletrpc\ncontext-linereturn await next({ ctx });\nframe\nmodule@trpc.server.dist:initTRPC-XuvQcOiC\nfunctioncallRecursive\nframe\nmodule@trpc.server.dist:initTRPC-XuvQcOiC\nfunctionprocedure\ncontext-lineconst result = await callRecursive(0, _def, opts);\ntypeTRPCError\n```\n\n### Raw Stack Trace\n```\nError: aborted\n File \"node:_http_server\", line 805, col 17, in abortIncoming\n File \"node:_http_server\", line 799, col 3, in socketOnClose\n File \"node:events\", line 530, col 35, in Socket.emit\n File \"node:net\", line 343, col 12, in TCP.?\n File \"node:internal/async_hooks\", line 130, col 17, in TCP.callbackTrampoline\nTRPCError: aborted\n File \"/app/node_modules/.pnpm/@trpc+server@11.4.4_typescript@5.8.3/node_modules/@trpc/server/dist/resolveResponse-9SiPu2EM.cjs\", line 53, col 11\n throw new require_tracked.TRPCError({\n File \"node:internal/process/task_queues\", line 105, col 5, in process.processTicksAndRejections\n File \"/app/node_modules/.pnpm/@trpc+server@11.4.4_typescript@5.8.3/node_modules/@trpc/server/dist/resolveResponse-9SiPu2EM.cjs\", line 59, col 12, in Object.read\n value = await promise;\n File \"/app/node_modules/.pnpm/@trpc+server@11.4.4_typescript@5.8.3/node_modules/@trpc/server/dist/resolveResponse-9SiPu2EM.cjs\", line 103, col 21, in getRawInput\n const inputs = await getInputs.read();\n File \"/app/node_modules/.pnpm/@sentry+core@10.5.0/node_modules/@sentry/core/build/esm/trpc.js\", line 54, col 26\n const rawRes = await getRawInput();\n File \"/app/node_modules/.pnpm/@trpc+server@11.4.4_typescript@5.8.3/node_modules/@trpc/server/dist/initTRPC-XuvQcOiC.mjs\", line 256, col 18, in callRecursive\n const result = await middleware((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {\n File \"/app/node_modules/.pnpm/@trpc+server@11.4.4_typescript@5.8.3/node_modules/@trpc/server/dist/initTRPC-XuvQcOiC.mjs\", line 256, col 18, in callRecursive\n const result = await middleware((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {\n File \"/app/packages/api/dist/trpc.js\", line 31, col 16\n return await next({ ctx });\n File \"/app/node_modules/.pnpm/@trpc+server@11.4.4_typescript@5.8.3/node_modules/@trpc/server/dist/initTRPC-XuvQcOiC.mjs\", line 256, col 18, in callRecursive\n const result = await middleware((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {\n File \"/app/node_modules/.pnpm/@trpc+server@11.4.4_typescript@5.8.3/node_modules/@trpc/server/dist/initTRPC-XuvQcOiC.mjs\", line 281, col 18, in procedure\n const result = await callRecursive(0, _def, opts);\n```\n\n\u003Cimg width=\"481\" height=\"797\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/0dd006b0-5218-4391-b3f2-34529429a0b5\" />\n\n### Important observations:\n- The issue **ONLY happens with a deployed backend** (it never happened when the backend ran locally)\n- **Raw `curl` requests ALWAYS work** (also with the exact same headers and body), while using a node-client with the httpBatchStreamLink _sometimes_ fails (at ~50% fail rate)\n- Only ~5-10% of the requests to the backend are *failure candidates* (which means that their request body _could_ lead to a failure)\n- With those _failure candidates_, only ~50% of the requests fail\n\nAfter a bit of debugging, it seemed like there is some race condition where an internal trpc abort controller would sometimes abort the request.\n\nI'd love to have support here since this issue already nags me for 2 days - and not being able to reproduce it (locally) makes it very hard to debug! \n\nMaybe you guys have a gut feel?\n\nThanks in advance!\n\n### Link to reproduction\n\nUnfortunately not able to.. reproduction requires a hosted backend for me.\n\n### To reproduce\n\nsee above\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!",[3205,3208],{"name":3206,"color":3207},"⏮ needs reproduction","000055",{"name":3172,"color":3173},6896,"bug: httpBatchStreamLink (occasionally) closes stream prematurely","2025-09-07T18:27:18Z","https://github.com/trpc/trpc/issues/6896",0.6050877,{"description":3215,"labels":3216,"number":3217,"owner":3175,"repository":3175,"state":3197,"title":3218,"updated_at":3219,"url":3220,"score":3221},"### Provide environment information\n\n```\r\n System:\r\n OS: macOS 12.5.1\r\n CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz\r\n Memory: 233.28 MB / 16.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 18.7.0 - /usr/local/bin/node\r\n Yarn: 1.22.19 - /usr/local/bin/yarn\r\n npm: 8.15.0 - /usr/local/bin/npm\r\n Browsers:\r\n Chrome: 104.0.5112.101\r\n Firefox: 103.0.2\r\n Safari: 15.6.1\r\n npmPackages:\r\n @trpc/client: ^9.26.0 => 9.26.0 \r\n @trpc/next: ^9.26.0 => 9.26.0 \r\n @trpc/react: ^9.26.0 => 9.26.0 \r\n @trpc/server: ^9.26.0 => 9.26.0 \r\n next: 12.2.0 => 12.2.0 \r\n react: 18.2.0 => 18.2.0 \r\n react-query: ^3.39.2 => 3.39.2 \r\n```\n\n### Describe the bug\n\nI need to write/read larger PNG Base64 strings to the database (3x 1MB). It works as long as the total file size of all three images is less than 700 KB. When the images are larger I get this error:\r\n```\r\nTRPCClientError: Unexpected token \u003C in JSON at position 0\r\n at Function.from (.../node_modules/@trpc/client/dist/TRPCClientError-bfee2bf5.cjs.dev.js:69:14)\r\n at .../node_modules/@trpc/client/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.dev.js:208:50\r\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {\r\n originalError: SyntaxError: Unexpected token \u003C in JSON at position 0\r\n at JSON.parse (\u003Canonymous>)\r\n at Response.json (node:internal/deps/undici/undici:2291:23)\r\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5),\r\n shape: undefined,\r\n data: undefined,\r\n isDone: false,\r\n [cause]: SyntaxError: Unexpected token \u003C in JSON at position 0\r\n at JSON.parse (\u003Canonymous>)\r\n at Response.json (node:internal/deps/undici/undici:2291:23)\r\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\r\n}\r\n```\r\n\r\nJust using prisma without trpc is working as well!\r\nuseMutation and useQuery without w+r images is also working.\n\n### To reproduce\n\n```javascript\r\n// Generate Base64:\r\n\r\nconst convertBase64 = (file: any) => {\r\n return new Promise((resolve, reject) => {\r\n const fileReader = new FileReader();\r\n fileReader.readAsDataURL(file)\r\n fileReader.onload = async () => resolve(fileReader.result)\r\n fileReader.onerror = (error) => reject(error)\r\n })\r\n}\r\n\r\nexport const handleFileRead = (Event: React.ChangeEvent\u003CHTMLInputElement>) => {\r\n const { files } = Event.target;\r\n const file = files?.[0]\r\n\r\n return convertBase64(file)\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!",[],2589,"bug: ","2022-08-29T14:01:07Z","https://github.com/trpc/trpc/issues/2589",0.615987,{"description":3223,"labels":3224,"number":3225,"owner":3175,"repository":3175,"state":3197,"title":3226,"updated_at":3227,"url":3228,"score":3229},"### Provide environment information\r\n\r\n```\r\n\r\n System:\r\n OS: macOS 12.5.1\r\n CPU: (8) arm64 Apple M1\r\n Memory: 157.83 MB / 16.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node\r\n Yarn: 1.22.19 - /opt/homebrew/bin/yarn\r\n npm: 8.19.1 - ~/.nvm/versions/node/v16.17.0/bin/npm\r\n Watchman: 2022.09.12.00 - /opt/homebrew/bin/watchman\r\n Browsers:\r\n Brave Browser: 106.1.44.105\r\n Chrome: 105.0.5195.125\r\n Firefox: 105.0.1\r\n Safari: 16.0\r\n npmPackages:\r\n @trpc/react: ^10.0.0-proxy-beta.15 => 10.0.0-proxy-beta.15\r\n react: 18.0.0 => 18.0.0 \r\n typescript: ~4.7.4 => 4.7.4 \r\n\r\n```\r\n\r\n### Describe the bug\r\n\r\nIf I create a trpc react proxy and client like:\r\n\r\n```typescript\r\nexport const trpc = createTRPCReact\u003CUserRouter>()\r\nexport const trpcClient: TRPCClient\u003CUserRouter> = trpc.createClient({\r\n links: [\r\n httpBatchLink({\r\n url: \"http://localhost:3000/user\"\r\n }),\r\n ],\r\n})\r\n```\r\n\r\nAnd try to use the `trpcClient` directly, it does not have the correct types:\r\n\r\n```typescript\r\n const createAccountResult = await trpcClient.mutation(\"account.create\")\r\n```\r\n\r\nWill return: `TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.`\r\n\r\n### Link to reproduction\r\n\r\nhttps://stackblitz.com/github/trpc/examples-next-minimal-starter\r\n\r\n### To reproduce\r\n\r\nSee above\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [X] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],2922,"bug: `TRPCClient` from `createTRPCReact\u003CRouterType>().createClient` is incorrectly typed","2022-10-05T23:29:07Z","https://github.com/trpc/trpc/issues/2922",0.6316328,{"description":3231,"labels":3232,"number":3233,"owner":3175,"repository":3175,"state":3197,"title":3234,"updated_at":3235,"url":3236,"score":3237},"### Provide environment information\r\n\r\n``` \r\nSystem:\r\n OS: macOS 12.2.1\r\n CPU: (10) arm64 Apple M1 Max\r\n Memory: 131.52 MB / 32.00 GB\r\n Shell: 3.2.57 - /bin/bash\r\n Binaries:\r\n Node: 18.8.0 - ~/.local/share/nvm/v18.8.0/bin/node\r\n Yarn: 1.22.19 - ~/.local/share/nvm/v18.8.0/bin/yarn\r\n npm: 8.18.0 - ~/.local/share/nvm/v18.8.0/bin/npm\r\n Browsers:\r\n Chrome: 106.0.5249.103\r\n Firefox: 105.0.2\r\n Safari: 15.3\r\n npmPackages:\r\n @trpc/client: ^10.0.0-proxy-beta.17 => 10.0.0-proxy-beta.17\r\n```\r\n\r\n\r\n### Describe the bug\r\n\r\nTypescript can't complete the typing of a query, see discussion https://github.com/trpc/trpc/discussions/2963\r\n\r\n\r\n`Property 'subscribe' does not exist on type 'DecoratedProcedureRecord\u003Cunknown, BuildProcedure\u003C\"subscription\", { _config: RootConfig\u003C{ ctx: {}; meta: {}; errorShape: never; transformer: CombinedDataTransformer; }>; _ctx_out: {}; _input_in: unique symbol; _input_out: unique symbol; _output_in: u\r\n nique symbol; _output_out: unique symbol; _meta: {}; }, Observable\u003C....'.`\r\n\r\n### Link to reproduction\r\n\r\nhttps://github.com/Lilja/trpc-v10-server-needed\r\n\r\n### To reproduce\r\n\r\nOpen up `src/index.ts` and modify the `type {AppRouter}` import, point it to the trpc repo OR a another router.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],2972,"bug: @trpc/server needed in the frontend for types to work","2022-10-11T08:18:00Z","https://github.com/trpc/trpc/issues/2972",0.6343751,{"description":3239,"labels":3240,"number":3242,"owner":3175,"repository":3175,"state":3197,"title":3243,"updated_at":3244,"url":3245,"score":3246},"### Provide environment information\r\n\r\n```\r\n System:\r\n OS: macOS 13.0.1\r\n CPU: (10) arm64 Apple M1 Max\r\n Memory: 60.66 MB / 32.00 GB\r\n Shell: 3.5.1 - /opt/homebrew/bin/fish\r\n Binaries:\r\n Node: 18.12.1 - /opt/homebrew/bin/node\r\n npm: 8.19.2 - /opt/homebrew/bin/npm\r\n Browsers:\r\n Chrome: 108.0.5359.94\r\n Safari: 16.1\r\n npmPackages:\r\n @trpc/server: ^10.4.3 => 10.4.3\r\n typescript: ^4.9.3 => 4.9.3\r\n```\r\n\r\n### Describe the bug\r\n\r\nGiven the following code:\r\n\r\n```ts\r\n const err = new TRPCError({\r\n code: 'FORBIDDEN',\r\n message: 'Some reason',\r\n });\r\n\r\n console.log('cause', err.cause);\r\n```\r\n\r\nThe cause is always an error with message `\"Unknown error\"`. I believe we should allow for the `error.cause` to be `undefined` in this situation instead.\r\n\r\n### Link to reproduction\r\n\r\nPlease see the \"Describe the bug\" section.\r\n\r\n### To reproduce\r\n\r\nPlease see the \"Describe the bug\" section.\r\n\r\n### Additional information\r\n\r\nThis seems to be due to the constructor of the `TRPCError` class: https://github.com/trpc/trpc/blob/24d23dac6a4e72b3f3569b4e6560100b37deeca0/packages/server/src/error/TRPCError.ts#L11-L20\r\nwhich calls `getErrorFromUnknown(opts.cause)` where `opts.cause` is `undefined`. [^1]\r\n\r\nWe end up going through this code: \r\n\r\nhttps://github.com/trpc/trpc/blob/24d23dac6a4e72b3f3569b4e6560100b37deeca0/packages/server/src/error/utils.ts#L17-L23\r\nhttps://github.com/trpc/trpc/blob/24d23dac6a4e72b3f3569b4e6560100b37deeca0/packages/server/src/error/utils.ts#L3-L15\r\n\r\nwhere `Unknown error` is the fallback value. \r\n\r\n\r\n[^1]: Aside: Code is checking for `opts !== undefined `, but I'm not sure if `opts` in the constructor can ever be undefined? Maybe in runtime in some situations? In which case case can be undefined.\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3241],{"name":3194,"color":3195},3351,"bug: cause on TRPCError is always set to \"Unknown error\" when no cause was given to constructor","2022-12-20T18:03:43Z","https://github.com/trpc/trpc/issues/3351",0.6426167,{"description":3248,"labels":3249,"number":3250,"owner":3175,"repository":3175,"state":3197,"title":3218,"updated_at":3251,"url":3252,"score":3253},"### Provide environment information\n\n```\r\n System:\r\n OS: macOS 13.1\r\n CPU: (10) arm64 Apple M1 Max\r\n Memory: 16.34 GB / 64.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node\r\n Yarn: 1.22.19 - ~/.nvm/versions/node/v18.4.0/bin/yarn\r\n npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm\r\n Browsers:\r\n Chrome: 110.0.5481.177\r\n Safari: 16.2\r\n npmPackages:\r\n @tanstack/react-query: ^4.24.10 => 4.24.10\r\n @trpc/client: ^10.13.2 => 10.13.2\r\n @trpc/react-query: ^10.13.2 => 10.13.2\r\n @trpc/server: ^10.13.2 => 10.13.2\r\n react: 18.1.0 => 18.1.0\r\n typescript: ^4.9.4 => 4.9.5\r\n```\n\n### Describe the bug\n\nNot sure if I want to track this as a client or a server bug, but I'm more worried about the server part.\r\n\r\nI know this request down there is not very realistic and was a result of an error where the client repeatedly asked for the same data. However I don't think this should result in a `404` from fastify.\r\n\r\nHere is the error that is happening:\r\n\r\n{\"level\":30,\"time\":1678292845000,\"pid\":739816,\"hostname\":\"ip-172-31-36-177\",\"reqId\":\"req-4\",\"msg\":\"Route GET:/trpc/outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending?batch=1&input=%7B%7D not found\"}\r\n\r\nUp until this point everything is fine, but this query then failed.\r\n\r\nHere's my fastify server config\r\n```ts\r\nimport initEnv from \"./lib/env\";\r\ninitEnv();\r\n\r\nimport { fastifyTRPCPlugin } from \"@trpc/server/adapters/fastify\";\r\nimport fastify from \"fastify\";\r\nimport { initFirebase } from \"./lib/firebase\";\r\nimport { mainRouter } from \"./api\";\r\nimport webHooks from \"./http-routes/web-hooks\";\r\nimport modelNotifications from \"./http-routes/model-notifications\";\r\nimport { createContext } from \"./lib/trpc\";\r\nimport {\r\n serializerCompiler,\r\n validatorCompiler,\r\n} from \"fastify-type-provider-zod\";\r\n\r\ninitFirebase();\r\n\r\nconst server = fastify({ logger: true });\r\n\r\nserver.setValidatorCompiler(validatorCompiler);\r\nserver.setSerializerCompiler(serializerCompiler);\r\n\r\nserver.register(modelNotifications);\r\nserver.register(webHooks);\r\n\r\nserver.register(fastifyTRPCPlugin, {\r\n prefix: \"/trpc\",\r\n trpcOptions: { router: mainRouter, createContext },\r\n});\r\n\r\nserver.get(\"/\", () => \"Running 🧘♀️\");\r\n\r\nserver\r\n .listen({\r\n host: \"0.0.0.0\",\r\n port: 3000,\r\n })\r\n .catch((err) => {\r\n server.log.error(err);\r\n process.exit(1);\r\n });\r\n```\r\n\n\n### Link to reproduction\n\nnone\n\n### To reproduce\n\nNot sure how to reproduce, but happens from time to time. Maybe someone has an idea just given the request.\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [X] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],3950,"2023-03-08T18:51:50Z","https://github.com/trpc/trpc/issues/3950",0.6486554,{"description":3255,"labels":3256,"number":3268,"owner":3175,"repository":3175,"state":3197,"title":3269,"updated_at":3270,"url":3271,"score":3272},"### Provide environment information\n\n```\nSystem:\n OS: macOS 15.1.1\n CPU: (10) arm64 Apple M1 Max\n Memory: 1.83 GB / 32.00 GB\n Shell: 5.9 - /bin/zsh\n Binaries:\n Node: 21.7.1 - ~/.nvm/versions/node/v21.7.1/bin/node\n Yarn: 1.22.22 - /opt/homebrew/bin/yarn\n npm: 10.5.0 - ~/.nvm/versions/node/v21.7.1/bin/npm\n Browsers:\n Chrome: 132.0.6834.160\n Safari: 18.1.1\n npmPackages:\n @tanstack/react-query: ^5.24.1 => 5.65.1 \n @trpc/client: 11.0.0-rc.730 => 11.0.0-rc.730+776d07336 \n @trpc/next: 11.0.0-rc.730 => 11.0.0-rc.730+776d07336 \n @trpc/react-query: 11.0.0-rc.730 => 11.0.0-rc.730+776d07336 \n @trpc/server: 11.0.0-rc.730 => 11.0.0-rc.730+776d07336 \n next: 14.2.3 => 14.2.3 \n react: 18.2.0 => 18.2.0 \n typescript: ^5.7.2 => 5.7.3 \n```\n\n### Describe the bug\n\nHello, and thank you for all your great work on this. We have run into a mysterious issue, that was initially a copy of https://github.com/trpc/trpc/issues/6374. We had initialized our `react-query` and tRPC clients per the [official docs](https://trpc.io/docs/client/react/setup), but were also using a `useEffect` to update some items used in our tRPC headers.\n\nWe removed the `useEffect` (as the headers are an `async` function anyway), and the untyped client error went away. However, we are now seeing `TRPCClientError: Headers is not defined`, although logging the headers in our React Native `AppContainer` component shows all the headers with values as expected.\n\nHere is our AppContainer:\n\n```ts\nconst AppContainer = () => {\n const [userID, setUserID] = useState('')\n\n // Navigation refs\n const navigationRef = useNavigationContainerRef\u003CRootStackParamList>()\n const routeNameRef = useRef\u003Cstring>()\n\n // Cached resources and color scheme\n const trpcUrl = useSessionStore((state) => state.trpcUrl)\n const userId = useSessionStore((state) => state.userId)\n\n // Device info\n const deviceBrand = Device.brand\n const deviceOS = Device.osName\n const deviceOSVersion = Device.osVersion\n const deviceModel = Device.modelName\n\n // tRPC and query clients\n const queryClient = new QueryClient()\n const [trpcClient] = useState(() =>\n trpc.createClient({\n links: [\n loggerLink({\n enabled: (opts) =>\n (process.env.NODE_ENV === 'development' && typeof window !== 'undefined') ||\n (opts.direction === 'down' && opts.result instanceof Error),\n console: {\n log: () => {\n // noop\n },\n error: (...args) => {\n logTrpcError(args)\n },\n },\n }),\n httpLink({\n url: trpcUrl,\n headers: async () => {\n // From AsyncStorage\n const customToken = await getItem('customToken')\n\n return {\n 'app-version': version,\n 'content-type': 'application/json',\n 'device-brand': deviceBrand || 'unknown',\n 'device-model': deviceModel || 'unknown',\n 'device-os-version': deviceOSVersion || 'unknown',\n 'device-os': deviceOS || 'unknown',\n 'custom-token': customToken || 'anonymous',\n 'user-id': userId || 'anonymous',\n }\n },\n }),\n ],\n }),\n )\n\n return (\n \u003Ctrpc.Provider client={trpcClient} queryClient={queryClient}>\n \u003CQueryClientProvider client={queryClient}>\n ...\n \u003C/QueryClientProvider>\n \u003C/trpc.Provider>\n )\n}\n```\n\nWe do not require any SSR in our project. Thank you very much for your time!\n\n### Link to reproduction\n\nN/A\n\n### To reproduce\n\nUnsure how to reproduce.\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!",[3257,3260,3263,3264,3265],{"name":3258,"color":3259},"🙋♂️ help wanted","008672",{"name":3261,"color":3262},"👻 invalid","e4e669",{"name":3206,"color":3207},{"name":3172,"color":3173},{"name":3266,"color":3267},"⏳ close if no activity","d4c5f9",6449,"bug: TRPCClientError \"Headers is not defined\"","2025-02-13T00:07:21Z","https://github.com/trpc/trpc/issues/6449",0.6508522,["Reactive",3274],{},["Set"],["ShallowReactive",3277],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$f6F0_xAP9FItVI_QgO1Caav2njP0xhwO3LERKvZL7NOo":-1},"/trpc/trpc/3359"]