Add 'send' and `end` to Worker Response object

#1

Now that KV is in place and large result sets may be possible, it would be useful to have send and end added as methods on the Response object in Workers. This would allow single results or blocks of results could be sent to the browser separately. As it is now, a Worker has to assemble all results into a single JSON object to send to the client. Since Response.body is a proper ReadStream in the browser, it would be trivial to write a client reader that could consume these one at a time. See also: Workers KV, Response Object Inadequate

0 Likes

#2

@adaptive … you seem to be in the know. Any thoughts on this. Seems imperative for KV at scale.

0 Likes

#3

Turns out there is a recipe that addresses this: https://developers.cloudflare.com/workers/recipes/streaming-responses/

0 Likes