You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add opt-in SSE support for server-to-client Streaming Methods #6044
Serverpod 4.1.2 uses WebSockets for Streaming Methods, including methods that take ordinary arguments and return a Stream. For features like AI chat, the client sends its input once and receives incremental results. Using SSE today requires a custom Web Route and separate client code for authentication, event decoding, and cancellation. Serverpod Streaming Methods documentation
Proposal
Let developers choose WebSocket or Server-Sent Events (SSE) per Streaming Method. Keep WebSocket as the default and require it for methods with stream parameters. Allow SSE for methods that return Stream and accept only ordinary arguments.
For SSE, the generated client could send an authenticated HTTP POST and decode each SSE data: event into T. Application code would still consume a typed Stream. Cancelling the subscription should close the HTTP response stream and release the server-side resources.
Use Case
A Flutter chat app sends a prompt and receives text deltas and a completion event as the model generates a reply. The developer can choose SSE while keeping the generated client, typed events, and existing Serverpod authentication.
Alternatives
A custom SSE Web Route can reuse the same chat service. That’s the workaround we use today. Built-in support would let developers use SSE through the same typed endpoint API they already use for WebSocket streams.
Activity