Skip to content

fix: send initial SSE keepalive in /api/flow to flush response headers#251

Open
vivekchand wants to merge 1 commit intomainfrom
fix/e2e-flow-sse-initial-headers-20260320
Open

fix: send initial SSE keepalive in /api/flow to flush response headers#251
vivekchand wants to merge 1 commit intomainfrom
fix/e2e-flow-sse-initial-headers-20260320

Conversation

@vivekchand
Copy link
Owner

Problem

The /api/flow SSE endpoint hangs on initial HTTP connection — curl -w '%{http_code}' returns 000 (timeout) instead of 200, causing E2E health checks to fail.

Root cause: Flask/waitress buffers the streaming response until actual data is yielded. Since /api/flow only yields events when new log activity occurs, a quiet dashboard causes HTTP headers to never flush, leaving clients stuck indefinitely.

Fix

Add SSE comment (: keepalive) as the very first yield in generate(). SSE comments are spec-valid and silently ignored by EventSource clients but force headers to flush immediately.

Impact

  • E2E health check returns HTTP 200 immediately
  • EventSource clients get connection confirmation without waiting
  • No behavior change for existing dashboard users

…s immediately

The /api/flow SSE endpoint was hanging on initial connection because the
Flask/waitress server buffers the response until data is yielded. Added a
keepalive SSE comment as the first yield so HTTP headers are flushed
immediately, allowing E2E health checks to verify the endpoint returns 200.

This also improves client compatibility — EventSource clients now receive
the connection confirmation without waiting for the first real event.

Fixes E2E test failure: curl -w '%{http_code}' returned 000 (timeout) instead of 200.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant