streaming responses being buffered
I'm unable to get a cloudflare worker to stream any responses using either readable stream or transform stream. Instead it's being buffered and sent as a single chunk once the response is complete. Are there specific configuration requirements? I've tried setting transfer-encoding header to chunked and said no-cache but it's still an issue. Is there a way to upgrade my workers or something so they can respond with streaming responses? Happy to provide my specific worker code if this is a skill issue.
5 Replies
Do you have a code example that reproduces it?
I already have a working example to stream xkb of files every 1s
here is example worker code that reproduces the issue. I expect
{"status":"processing"}
then {"status":"success","data":{"fileText":"Page1 Page2","numPages":2}}
but instead I get nothing and then {"status":"processing"}{"status":"success","data":{"fileText":"Page1 Page2","numPages":2}}
all at once
I'm uncertain if there's a configuration change I need to makeHow are you testing it? It seems fine for me in Chrome.
@kian thank you for your reply. i went down a deep rabbit hole. i realized curl needed
-N
param, once I added that it worked. Then i started with plain JS, it worked. Then a clean nextJS app, it worked. Then I figured out I had a middleware issue in my nextjs app that was causing my fetch requests to buffer. Thanks!