Skip to content

refactor(executions): Replace WebSocket execution updates with Server-Sent Events (SSE) #7

Description

@ABUDIYAAAA

Execution progress updates are currently delivered over WebSockets.

However, execution events are strictly server → client. The client does not need to continuously send data back to the server over the same connection, making WebSockets unnecessarily complex for this use case.

Migrating to Server-Sent Events (SSE) would simplify the implementation while reducing resource usage and maintenance overhead.


Problem

WebSockets provide full-duplex communication, but execution monitoring only requires one-way event streaming.

Using WebSockets introduces unnecessary complexity such as:

  • WebSocket connection lifecycle management
  • Ping/Pong heartbeat handling
  • Additional memory usage per active connection
  • More complex reconnection logic
  • Higher operational overhead for infrastructure that only pushes events

For a feature that only streams execution updates, this is more capability than we actually require.


Proposed Solution

Replace the execution update transport layer with Server-Sent Events (SSE).

Execution flow would become:

  1. Client starts an execution (HTTP)
  2. Client opens an SSE stream for that execution
  3. Server streams execution lifecycle events
  4. Connection closes automatically when execution completes

Benefits

Reduced Resource Usage

  • Lower memory footprint per connection
  • Less protocol overhead
  • No bidirectional socket management

Simpler Implementation

  • Native browser EventSource
  • Automatic reconnection
  • Plain HTTP endpoint
  • Easier debugging using standard HTTP tooling

Better Fit for the Use Case

Execution updates are naturally append-only events flowing from server to client.

SSE is purpose-built for this communication pattern.


Considerations

  • User actions (cancel execution, retry, etc.) should continue using standard HTTP endpoints.
  • Existing event payloads should remain unchanged where possible to minimize frontend changes.
  • Streaming endpoint should terminate once execution reaches a terminal state.
  • Authentication should match existing HTTP authentication middleware.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions