Skip to content

Feat: Streaming - #4960

Closed
helmturner wants to merge 17 commits into
mainfrom
feat-streaming
Closed

helmturner wants to merge 17 commits into
mainfrom
feat-streaming

Conversation

@helmturner

@helmturner helmturner commented Oct 26, 2023 •

Copy link
Copy Markdown

Closes #4530, #4477, #544, #1853

🎯 Changes

TBD

βœ… 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.

@vercel

vercel Bot commented Oct 26, 2023

Copy link
Copy Markdown

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

Name Status Preview Updated (UTC)
next-prisma-starter βœ… Ready (Inspect) Visit Preview Oct 26, 2023 11:31am
og-image βœ… Ready (Inspect) Visit Preview Oct 26, 2023 11:31am
trpc-next-app-dir βœ… Ready (Inspect) Visit Preview Oct 26, 2023 11:31am
www βœ… Ready (Inspect) Visit Preview Oct 26, 2023 11:31am

@KATT KATT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some random thoughts/comments

Comment on lines +151 to +161
const officialTsonSyncHandlers = [
tsonBigint,
tsonDate,
tsonRegExp,
tsonSet,
tsonMap,
tsonUndefined,
tsonNumberGuard,
tsonURL,
tsonSymbol,
] as const;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure we should be adding a bunch of transformers automatically as it is quite a big change,

I'd rather have only support for Promise and AsyncIterable and let the user define the others

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So, if I understand, were basically just defaulting to JSON for sync types, since tupleson only tuplefies non-json-serializables? By the way, I missed that little detail for way too long, and may have made some assumptions that rely on ALL serialized values being wrapped in a tuple (with nonce)

Comment on lines +197 to +200
return {
input: _createTson('input'),
output: _createTson('output'),
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Won't creating the transformer here and in the resolveHttp create two different instances that have different nonce and contains two different "heads"?

Will likely not cause any issues, but it'd be nicer if they'd use the same instance

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hmm, did I miss some lazy initialization of the revolvers? I didn't realize I was instantiating twice. Can you link the line?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I fail to see why we need this big complex file - I think the complexity here should be handled by tupleson for any streaming responses

E.g.

case 'tupleson-json': {
const toResponse = createTsonSerializeJsonStreamResponse(
router._def._config.experimental_tuplesonOptions as any,
);
return toResponse(
promises.map((p) =>
p.then((result) => {
// transform
return transformTRPCResponse(router._def._config, result);
}),
),
);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep, that's cruft that hasn't been removed yet. Just there for reference.

@KATT

KATT commented Nov 17, 2023

Copy link
Copy Markdown
Member

#4911

@KATT KATT closed this Nov 17, 2023
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 17, 2023
@KATT
KATT deleted the feat-streaming branch November 1, 2024 11:22

This branch was successfully deployed

5 active deployments
Preview – trpc-next-app-dir β€” 66cd1636 Deployed Oct 24, 2023 by vercel[bot]
Preview – www β€” 66cd1636 Deployed Oct 24, 2023 by vercel[bot]
Preview – todomvc β€” 66cd1636 Deployed Oct 24, 2023 by vercel[bot]
Preview – og-image β€” 66cd1636 Deployed Oct 24, 2023 by vercel[bot]
Preview – next-prisma-starter β€” 66cd1636 Deployed Oct 24, 2023 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

2 participants