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

Support Streaming #79

Closed
fwang opened this issue Apr 11, 2023 · 7 comments · Fixed by #213
Closed

Support Streaming #79

fwang opened this issue Apr 11, 2023 · 7 comments · Fixed by #213

Comments

@fwang
Copy link
Contributor

fwang commented Apr 11, 2023

AWS Lambda just introduced streaming capabilities via Lambda URLs. Opening this issue to gather some thoughts/interests from the community.

Ref:
https://beta.nextjs.org/docs/data-fetching/streaming-and-suspense
https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/

@conico974
Copy link
Collaborator

Definitely interested in this.
One of the issue with lambda response streaming as of now is that it only support lambda function url.
I've started playing with it yesterday to see if it would be difficult to support and it should not be to difficult, but we need to figure out how to support both edge and standard lambda : conico974@688150d

@khuezy
Copy link
Collaborator

khuezy commented Apr 20, 2023

@conico974 were you able to cache the streamed data? I tried playing w/ streaming in server-adapter but the content type ended up being an octet-stream

@conico974
Copy link
Collaborator

Yes it was kind of working, i hacked something here : https://github.com/conico974/open-next/blob/688150d0a09d78a12f0ba926097c8282b6ec2745/packages/open-next/src/adapters/response.ts#L85 to set the content type.
This was the only way i found to set the headers on the response stream, but i haven't looked too much into this.

There is also a setContentType method on the responseStream object but we need to call this before writing anything to the stream, otherwise it will log an error and set the content type to octet-stream

@DavidHooper
Copy link

@conico974 I've forked your commit and investigating further. Found this function sets content type after the stream has already been written to.
https://gist.github.com/magJ/63bac8198469b6a25d5697ad490d31e6#file-index-mjs-L806

@conico974
Copy link
Collaborator

@DavidHooper Nice catch looking at the runtime.
This function is actually called from user code, so it's likely something i have done or that you've done.
Looking at the gist, the response stream provided to us is actually https://gist.github.com/magJ/63bac8198469b6a25d5697ad490d31e6#file-index-mjs-L197.
We should probably rewrite the response class from open-next around that class

@ian-pascoe
Copy link

Is there any update on this? I would love to see it implemented!

@khuezy
Copy link
Collaborator

khuezy commented Sep 8, 2023

@passgoco https://discord.com/channels/983865673656705025/1027265626085019769/1149742408565800990
Still experimental, chunks aren't compressed, we're looking into rewriting the http server. Help us if you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants