<T = unknown>(c: Context<any, any, {}>, log: Logger, options?: SseResponseOptions | undefined): { response: Response; stream: SseStream<T>; } import {create_sse_response} from '@fuzdev/fuz_app/realtime/sse.js'; Create an SSE response for a Hono context.
Wraps Hono's streamSSE to provide a {response, stream} API
compatible with SseRegistry push-based broadcasting.
The callback suspends via a promise that resolves on client disconnect
or explicit close(), keeping the stream alive for external sends.
The stream closes when its client disconnects, whenever that happens — also
before the handler returns the response, which no runtime reports by
cancelling the body. A client already gone when this is called yields a
stream that is already closed, so register cleanup with on_close (which
runs a late listener at once) before handing the stream anywhere that would
count it — SseRegistry.admit after on_close(pending.unsubscribe)
refuses it.
Uses hono_stream.write() directly (not writeSSE) to avoid
Hono's HTML callback resolution — keeps the same data: JSON\n\n format.
What the stream holds unread is bounded by SSE_OUTBOUND_QUEUE_BYTES; a frame past it ends the stream (module doc, "Outbound bound").
c
Context<any, any, {}>log
logger for serialization and on_close listener errors, and
for the warning when the stream ends on its outbound budget
Loggeroptions?
what the overflow warning names, and the keep-alive interval
returns
{ response: Response; stream: SseStream<T>; } object with the streaming Response and an SseStream controller
generics
create_sse_response<T = unknown>T
unknownthrows
Error- when `options.keep_alive_ms` is out of range (`validate_sse_keep_alive_ms`)