Skip to content

Adding a streaming option for batched requests - #4346

Merged
Sheraff merged 18 commits into
trpc:feat/out-of-order-batch-responsefrom
Sheraff:main
May 11, 2023
Merged

Sheraff merged 18 commits into
trpc:feat/out-of-order-batch-responsefrom
Sheraff:main

Conversation

@Sheraff

@Sheraff Sheraff commented May 10, 2023 •

Copy link
Copy Markdown
Contributor

❗️❗️
This PR was started on a fork of trpc, and has now been brought into trpc. Work will continue there: #4347
❗️❗️


Closes #4343

🎯 Changes

Should work as is (though untested), but this doesn't (yet) actually handle the responses as a stream client-side.

The only major change (except for the streaming stuff obviously) is that the data key of the argument passed to opts.responseMeta is now optional, because it cannot be known in the case of a streamed response. I haven't looked too deeply into how this responseMeta function is declared, but if really necessary, we might be able to type it correctly so that data is not optional when batching: { enabled: boolean } isn't set to true

βœ… Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

🚧 TODO

@vercel

vercel Bot commented May 10, 2023

Copy link
Copy Markdown

@Sheraff is attempting to deploy a commit to the trpc Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented May 10, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
www βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback May 11, 2023 7:28am

@Sheraff
Sheraff changed the base branch from main to feat/out-of-order-batch-response May 11, 2023 08:26
@Sheraff
Sheraff marked this pull request as ready for review May 11, 2023 08:26
@Sheraff
Sheraff merged commit c864c4b into trpc:feat/out-of-order-batch-response May 11, 2023
@@ -10,6 +10,9 @@ export interface BaseHandlerOptions<TRouter extends AnyRouter, TRequest> {
batching?: {
enabled: boolean;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My opinion of the public facing API:

batching?: { enabled: true, streaming: boolean } | { enabled: false }

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 12, 2023

This branch had an error being deployed

1 failed and 1 active deployments
Preview – www β€” 10a0c659 Deployed May 11, 2023 by vercel[bot]
Preview – todomvc β€” 10a0c659 Deployed May 11, 2023 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: out-of-order batch response streaming

2 participants