Skip to content

fix(bff,ui): prevent SSE write-after-close and improve stream error handling - #113

Merged
guimou merged 1 commit into
devfrom
fix/sse-connection-resilience
Aug 10, 2026
Merged

guimou merged 1 commit into
devfrom
fix/sse-connection-resilience

Conversation

@guimou

@guimou guimou commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • BFF: Guard SSE writes against closed connections — track state via res.on('close'), skip res.write()/res.end() after client disconnect, and clear the heartbeat interval on close. Prevents ERR_INCOMPLETE_CHUNKED_ENCODING errors caused by intermediate proxy timeouts during long Helm operations.
  • Frontend: Catch network errors from reader.read() during SSE streaming and throw StreamInterruptedError with a user-friendly message instead of surfacing raw TypeError. Preserve last-known step progress in the modal on stream interruption.

Same fix as rh-ai-community-plugins/quickstarts-manager — both plugins share the same SSE pattern and were affected by the same bug.

Test plan

  • All existing tests pass (235 frontend + 181 BFF)
  • Lint passes for both frontend and BFF
  • Deploy plugin, install a chart, and verify SSE progress modal completes without error
  • Simulate proxy timeout (e.g. kill the dashboard proxy mid-install) and verify the modal shows "Connection lost during operation" instead of "Network error"

…andling

During long-running Helm operations, intermediate proxies (RHOAI
dashboard proxy, OpenShift Router/HAProxy) can sever the SSE
connection. This caused ERR_INCOMPLETE_CHUNKED_ENCODING in the browser
and a generic "Network error" in the progress modal, even though the
operation completed successfully in the background.

BFF: track connection state via res.on('close') and guard all
res.write/res.end calls — prevents writing to a dead socket and
leaking the heartbeat interval.

Frontend: catch network errors from reader.read() during SSE streaming
and surface a user-friendly "Connection lost" message instead of raw
TypeError. Preserve last-known step progress in the modal on
stream interruption.
@guimou
guimou merged commit 74ecb39 into dev Aug 10, 2026
3 checks passed
@guimou
guimou deleted the fix/sse-connection-resilience branch August 10, 2026 15:39
@guimou guimou mentioned this pull request Aug 10, 2026
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