Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tRPC mutations hang if request body already read #5534

Open
1 task
aseemk opened this issue Mar 3, 2024 · 1 comment
Open
1 task

tRPC mutations hang if request body already read #5534

aseemk opened this issue Mar 3, 2024 · 1 comment
Labels
📚 documentation / examples Improvements or additions to documentation

Comments

@aseemk
Copy link

aseemk commented Mar 3, 2024

Area of Improvement

Hi there. Thanks for such a great library!

I hit an issue trying to use it for the first time, where queries worked but mutations would hang indefinitely, and never execute my actual procedure (function).

I managed to figure it out, but thought it might be worth documenting this more explicitly, to save others the hours of debugging.

The cause was that:

  • Mutation inputs come through the request body (whereas query string inputs come through the query string)

  • tRPC's Node HTTP adapter (which other adapters, like this Koa adapter I'm using, wrap) thus attempts to read/stream the request body

  • But I was already using another middleware to read/stream request bodies for other uses in my app.

So tRPC was indefinitely waiting around for data and end events that never came.

Fortunately, tRPC's Node HTTP adapter does support the native Node request already having a body property set. And in my case, the other middleware I'm using does provide an option to add this property to the native Node request (in addition to the Koa context's request).

So consider documenting this important detail and gotcha, whether in the adapters page(s) and/or the troubleshooting page.

Thanks and hope this helps others!

Link to related docs

No response

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR implementing the suggested changes!

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@aseemk aseemk added the 📚 documentation / examples Improvements or additions to documentation label Mar 3, 2024
@KATT
Copy link
Member

KATT commented Mar 3, 2024

Where would you think this should be documented? Feel free to just click edit on some of the pages on the trpc docs and submit a pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation / examples Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants