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

Streaming responses #114

Open
geoffrich opened this issue Feb 17, 2023 · 6 comments
Open

Streaming responses #114

geoffrich opened this issue Feb 17, 2023 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@geoffrich
Copy link
Owner

geoffrich commented Feb 17, 2023

An upcoming SvelteKit feature will support streaming non-essential data so pages load quicker for platforms that support it. This adapter currently does not support streaming, since the entire response is buffered before returning:

async function toResponse(rendered) {
const { status } = rendered;
const resBody = new Uint8Array(await rendered.arrayBuffer());
const { headers, cookies } = splitCookiesFromHeaders(rendered.headers);
return {
status,
body: resBody,
headers,
cookies,
isRaw: true
};
}

The effect of this is that pages will wait for the entire data response to be ready instead of showing data as soon as it is available.

I'm not sure if Azure functions support streaming, but if they do, we should update this adapter to stream responses instead of buffering them.

EDIT: this is the SvelteKit feature in question: streaming promises.

@geoffrich geoffrich added the help wanted Extra attention is needed label Feb 17, 2023
@tlaundal
Copy link
Contributor

I think this is blocked by Azure/azure-functions-host#1361.

I spun up a function just to test if it was somehow supported, but couldn't find a way to return a stream.

@thomasgauvin
Copy link

Agree with tlaundal, I think support for streaming is dependent on that so blocked for now

@geoffrich geoffrich added blocked-by-upstream and removed help wanted Extra attention is needed labels Mar 11, 2023
@dslatkin
Copy link

dslatkin commented Nov 8, 2023

According to this comment from a Microsoft employee:

We have a lot of exciting new features in the works (top of mind is stream support)

So at least it sounds like it's being actively worked on. 🙂

@geoffrich
Copy link
Owner Author

Azure announced preview support for Node.js streams: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-functions-support-for-http-streams-in-node-js-is-now-in/ba-p/4066575

@geoffrich geoffrich added help wanted Extra attention is needed and removed blocked-by-upstream labels Feb 28, 2024
@geoffrich
Copy link
Owner Author

Putting "help wanted" on this, in case someone wants to try updating the adapter themselves. I'll get to it eventually but not sure when I'll have time.

@geoffrich
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants