Skip to content

v3.10.70 — SSE/Streaming Support

Choose a tag to compare

@andrevanzuydam andrevanzuydam released this 06 Apr 08:13

v3.10.70 — SSE / Streaming Support

New Feature: res.stream()

Server-Sent Events (SSE) support. Pass an async iterable to res.stream() and the framework uses native ServerResponse.write() for chunked streaming with SSE headers.

Quick Example

export default async function (req, res) {
  res.stream(async function* () {
    for (let i = 0; i < 10; i++) {
      yield `data: message ${i}\n\n`;
      await new Promise(r => setTimeout(r, 1000));
    }
  }());
}

What's Included

  • res.stream(asyncIterable, contentType?) method
  • Type definition added to Tina4ResponseMethods
  • Native ServerResponse.write() for zero-copy streaming
  • SSE headers via writeHead()
  • 24 new SSE tests
  • Feature count: 45
  • Full parity with Python, PHP, Ruby