tRPC duplicate header Transfer-Encoding: chunked

hey, i tried deploying my nextjs + trpc app to production but when i set up a reverse proxy i got stuck on such error: nginx: upstream sent duplicate header line: "Transfer-Encoding: chunked" traefik, caddy: net/http: HTTP/1.x transport connection broken: too many transfer encodings: [\"chunked\" \"chunked\"] basically i tried those 3 options which all of them "failed" what can i do now cause looks like its a tRPC error rather it happens when i try to invoke a procedure and it works correctly on the backend but the response doesnt come and i get Stream closed error
13 Replies
Adam Borygo
Adam BorygoOP•4mo ago
after investigating a bit in nginx i can see that it indeed sends it twice:
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy status 200 "200 OK"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Vary: rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch, trpc-accept, Accept-Encoding"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Content-Type: application/json"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Transfer-Encoding: chunked"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Content-Encoding: gzip"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Date: Sat, 23 Aug 2025 19:59:06 GMT"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Transfer-Encoding: chunked"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy status 200 "200 OK"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Vary: rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch, trpc-accept, Accept-Encoding"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Content-Type: application/json"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Transfer-Encoding: chunked"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Content-Encoding: gzip"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Date: Sat, 23 Aug 2025 19:59:06 GMT"
reverse-proxy-1 | 2025/08/23 19:59:07 [debug] 30#30: *5 http proxy header: "Transfer-Encoding: chunked"
what can i do to fix this? is this an issue on my end somehow?
Adam Borygo
Adam BorygoOP•3mo ago
explained more here + reproduction: https://github.com/trpc/trpc/issues/6909
GitHub
bug: tRPC sends duplicate header Transfer-Encoding: chunked · Issu...
Provide environment information System: OS: macOS 15.4.1 CPU: (10) arm64 Apple M2 Pro Memory: 133.44 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/...
JacobMGEvans
JacobMGEvans•3mo ago
You seem to have reported it in the correct place, being the GitHub issue for the tRPC project... Not sure what you expect by having it posted here?
Adam Borygo
Adam BorygoOP•3mo ago
cause this place seems more active than trpc github issues
JacobMGEvans
JacobMGEvans•3mo ago
But we arent the maintainers, if that is a bug 😅
Adam Borygo
Adam BorygoOP•3mo ago
maybe someone encountered something like this, maybe its not a trpc bug and im doing something wrong. better to ask than not to
JacobMGEvans
JacobMGEvans•3mo ago
Wait are you using Traefik, Caddy AND NGINX or just tried each one?
Adam Borygo
Adam BorygoOP•3mo ago
i tried with each one of them, each failed with same error being duplicated header but it seems kind of weird to me that no one else tried deploying to production a nextjs + trpc under a reverse proxy. Cause when i tried searching for this error i found like nothing. Do you happen to know any production ready github repos with trpc i could look into?
JacobMGEvans
JacobMGEvans•3mo ago
Are you forwarding the headers?
Adam Borygo
Adam BorygoOP•3mo ago
yea, i belive nginx by default forwards all the headers the minimal reproduction nginx.conf is included in the repo also: https://github.com/DownDev/trpc-bug/blob/main/nginx.conf
JacobMGEvans
JacobMGEvans•3mo ago
Hmm, how is your tRPC server configured? Oh I see...
Adam Borygo
Adam BorygoOP•3mo ago
https://github.com/DownDev/trpc-bug its all here, basically its the default config from create-t3-app @JacobMGEvans managed to resolve this, basically i switched the image used in Dockerfile i was using bun:latest when i downgraded to bun:1.1.45-alpine it works, but for example version like bun:1.2-alpine doesnt work idk seems like newer versions dont work weird.
JacobMGEvans
JacobMGEvans•3mo ago
Oh crazy, you should hit up Bun for sure

Did you find this page helpful?