SSE (Server-Sent Events) infrastructure for real-time run updates.
Endpoints (INF-005: all under /api/v1/)
| Method | Path | Description |
|---|---|---|
GET |
/api/v1/runs/:runId/events |
SSE stream for a single run |
Exports
emitRunEvent— Broadcast an event to all listeners on a run.runListeners—Map<runId, Set<res>>— active SSE connections.
- Source:
Members
(inner, constant) CHANNEL_PREFIX
Redis channel prefix for run events.
- Source:
(inner, constant) _instanceId
Unique identifier for this server instance — used to skip self-echo from Redis.
- Source:
(inner, constant) _subscribedRuns
Set of runIds this instance is subscribed to (avoids duplicate subscribes).
- Source:
Methods
(static) emitRunEvent()
emitRunEvent(runId, type, payload)
Broadcasts a Server-Sent Event to every client listening on this run. Called from testRunner.js and crawler.js to push live updates.
When Redis is available, the event is also published to a Redis channel
so other server instances can relay it to their connected SSE clients.
The local delivery happens first (instant), then Redis pub (async).
The message includes an _origin field so the subscriber can skip
messages published by this same instance (preventing duplicate delivery).
- Source:
(inner) _deliverToLocal(runId, type, data)
Deliver an SSE event to locally connected clients for a given run. Separated from emitRunEvent so the Redis subscriber can call it too.
Parameters:
| Name | Type | Description |
|---|---|---|
runId |
string | |
type |
string | — event type (for "done" cleanup logic) |
data |
string | — pre-serialised JSON string |
- Source:
(inner) _subscribeToRun(runId)
Subscribe to the Redis channel for a run (if not already subscribed).
Parameters:
| Name | Type | Description |
|---|---|---|
runId |
string |
- Source:
(inner) _unsubscribeFromRun(runId)
Unsubscribe from the Redis channel for a run (when no local listeners remain).
Parameters:
| Name | Type | Description |
|---|---|---|
runId |
string |
- Source: