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 dynamic server responses are buffered when testing with wrangler dev #1237

Closed
rmarscher opened this issue Feb 17, 2025 · 3 comments · Fixed by #1242
Closed

Streaming dynamic server responses are buffered when testing with wrangler dev #1237

rmarscher opened this issue Feb 17, 2025 · 3 comments · Fixed by #1242

Comments

@rmarscher
Copy link
Contributor

rmarscher commented Feb 17, 2025

It doesn't happen in production with a Cloudflare Worker or with waku dev. I found a related issue in the workers-sdk repo. It seems to be due to automatic compression of html and txt responses. It looks like there is a workaround - but I think we can wait for an upstream fix to #8004.

@rmarscher
Copy link
Contributor Author

@rmarscher rmarscher changed the title wrangler dev buffers suspense responses Streaming dynamic server responses are buffered when testing with wrangler dev Feb 17, 2025
@hamlim
Copy link
Contributor

hamlim commented Feb 17, 2025

I remember seeing a similar workaround noted in the Hono docs for streaming as well, see callout below the code block here: https://hono.dev/docs/helpers/streaming#streamtext

@rmarscher
Copy link
Contributor Author

There is more context in this comment.

I came up with a way to detect if the server is running on production Cloudflare Workers vs the wrangler dev command. It is tricky. There are only a few headers that are different so I picked the most reliable one. Another option could be to use an environment variable to decide if the Identity encoding header should be set.

We don't want to enable it in production. If we do, the responses aren't compressed. I verified in #1242 that production responses still have the zstd compression automatically added by Cloudflare but streaming works.

Image

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.

2 participants