-
Notifications
You must be signed in to change notification settings - Fork 558
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 BUG: vercel/ai
streaming broken with 3.50.0
in dev | unexpected gzip
compression
#5614
Comments
Vercel/AI
streaming broken with 3.50.0
vercel/ai
streaming broken with 3.50.0
in dev | unexpected gzip
compression
Hi @flexchar! Can you please provide a minimal reproduction of this bug where running with |
I'm am seeing the same thing with my AI-based app. on 3.49.0, I get responses streamed back (with no Unfortunately my code is not public and getting all the pieces in places for a minimal reproduction would take quite awhile so I'm going to pin to 3.49.0 for now. |
Hey, yes! I am insanely busy, I put this on my todo this weekend. Sorry for the delay! |
A couple notes... If I add a Also, in my app in production, there is no Thanks for taking a look! Here's an example of the code I added to work around this in dev:
|
Reproducible https://github.com/flexchar/workers-sdk-issue-5614 |
Similar issue with the simplest of proxy workers. Streaming requests are fully buffered before responding when using the latest wrangler 3.52.0, while 3.49.0 works as expected. export default {
async fetch(request, environment, context) {
return fetch(new Request('http://localhost:7777/', request));
}
} |
I'm seeing the exact same behavior as @teak. I investigated more and discovered the same I had previously filed a bug, but hadn't yet collected this additional piece of info. This can be worked around by manually gzipping and chunking the response that wrangler sends, and forward the altered response to the client. |
This should be fixed by #5798 Please try with |
Is it possible this still present in Wrangler |
I'm not seeing any issue with Wrangler |
Which Cloudflare product(s) does this pertain to?
Workers Runtime
What version(s) of the tool(s) are you using?
3.50.0
What version of Node are you using?
v21.7.1
What operating system and version are you using?
macOS 14.4.1
Describe the Bug
vercel/ai
library provides easy to implement streaming for OpenAI. After upgrade to latest version the streaming is not output until it's completely done buffering. This is in development. I cannot deploy as that would break the clients. Once I can, I will test.I am also using HonoJS however it did not change. I am not using any compression middlewares etc.
Observed behavior
The streaming is buffered until AI provider is finished.
Expected behavior
Should not be buffered.
Steps to reproduce
Reproducible https://github.com/flexchar/workers-sdk-issue-5614
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
I noticed that the broken response includes
Content-Encoding: gzip
header. Compressing would explain why buffering is not working.As such, appending header to disable compression alleviates the issue:
Reference https://sdk.vercel.ai/docs/api-reference/streaming-text-response#example
Might be related:
Accept-Encoding: identity
for AI API requests聽#5713The text was updated successfully, but these errors were encountered: