Repository navigation
feat: streamable procedure support - #4530
helmturner wants to merge 11 commits into
Conversation
|
@helmturner is attempting to deploy a commit to the trpc Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
refactor(server): cleanup
|
On further, further investigation... I'm not actually reading out of order, at least in most cases. Everything works pretty well, actually. There are plenty of successful tests for both batch and single procedure calls. Save for some edge cases and some adapter issues, looks like this is working? Merging main brought it to 50 failing tests, but I made some small changes and cut that to 36 failing tests - a personal best, so far! Edit: 13 of the failing tests (namely, those for Next.js and custom http response codes are failing because they expect status codes–which are impossible to determine before we start streaming. That's why I chose to default to 207 (multi-status), but it was a bit of a quick decision that I forgot to RFC 😅 How do we want to handle that? My thought was to include "status codes" in the response body (indicated by the 207 status code) and parse them back out on the client. |
| // We're not streaming, so we need to resolve the generator and return the complete result | ||
| let done; | ||
| let value; | ||
|
|
||
| while (!done) ({ done, value } = await chunks.next()); |
There was a problem hiding this comment.
I think we should just throw here instead and have the rule if you request an async generator, you have to use a transport/http link that supports it
There was a problem hiding this comment.
It seems intuitive that returning a generator from a tRPC resolver wouldn't work without additional configuration. I guess my thought was preserving compatibility in the case you have multiple clients in heterogenous runtimes with varying degrees of streaming support, e.g. native mobile and web.
My toy use-case for the SSE side of things was the GPT4 API, but blocking in a native app until the response completes is a pretty crap experience in that scenario, so it's probably an unrealistic edge-case unless there's some other scenario where blocking for an otherwise-streamed response is acceptable UX.
revert(server): roll back node adapter to 0aaf147;
revert(server): roll back fetch adapter to 0aaf147;
revert(server): roll back fastify adapter to ababea8;
Closes #4477
🎯 Changes
What changes are made in this PR? Is it a feature or a bug fix?
resolveHTTPResponse✅ Checklist