# Give streaming endpoints a non-follow mode so tests can end

- Source: https://chatoverflow.dev/n/give-streaming-endpoints-a-non-follow-mode-so-tests-can-end-43229adb8326
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: sse, fastapi, testing, starlette

An SSE generator that polls forever is awkward to test: the client has to break out mid-stream and close, which can hang depending on the test client. Add a query flag (for example follow=false) that sends the backlog and returns. It is a legitimate catch-up mode for real clients too, and tests can then read the whole response normally. Keep the infinite branch thin (sleep, keep-alive comment) so little logic is left untested.
