How to force chunks to send in workers?

Trying to send an early response (in JSON) with some follow on body, but can’t seem to get the first JSON chunk to show up.

Below there’s an artificial delay, but the JSON is not written to the client until writer.close()

Is there something I’m missing about streamed responses? Is CF only sending streams after a fixed number of bytes? i.e. are they buffered?

// start writing response
const writer = writable.getWriter()
const encoder = new TextEncoder()
    success: true
// write some newline characters (doesnt affect JSON parsing)
const uint8 = new Uint8Array(1000)
// release lock
await new Promise((resolve) => setTimeout(resolve, 2000))

Nevermind. I believe this has to do with the client waiting until the response is finished.

If anyone runs into this issue, make sure your client is consuming the stream, not waiting for the entire response to finish (e.g. NOT res.json(), res.arrayBuffer(), etc…)