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 error13 Replies
after investigating a bit in nginx i can see that it indeed sends it twice:
what can i do to fix this? is this an issue on my end somehow?
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/...
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?
cause this place seems more active than trpc github issues
But we arent the maintainers, if that is a bug 😅
maybe someone encountered something like this, maybe its not a trpc bug and im doing something wrong. better to ask than not to
Wait are you using Traefik, Caddy AND NGINX or just tried each one?
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?
Are you forwarding the headers?
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.confHmm, how is your tRPC server configured?
Oh I see...
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.Oh crazy, you should hit up Bun for sure