You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[sagas] SSE event feed scans the keyspace every 100 ms per client and loses events #2637
The saga SSE event feed writes each event as a KV key, polls the whole prefix every 100 ms per connected client, and deletes the key once one client has sent it. Each client causes ten keyspace scans per second, and with more than one client only one of them receives a given event.
plugins/sagas/services/src/routers/v1-handlers.ts:184-197: kv.watchPrefix(['saga', 'events'], { pollInterval: 100 }), then kv.delete(watchEvent.key) after the event is yielded.
plugins/sagas/services/src/routers/v1-handlers.ts:305-308: kv.set(['saga', 'events', crypto.randomUUID()], event). The random key gives no order.
On the Redis KV adapter, watchPrefix runs a SCAN + MGET sweep per interval (packages/kv/adapters/redis.adapter.ts).
The event id is a per-connection counter, so Last-Event-ID cannot resume a feed.
Expected behavior
Every connected client receives every event in publish order, a reconnecting client resumes from its last event id, and an idle feed does not scan the keyspace.
Acceptance
Two concurrent clients both receive every published event, proven by a test that fails on current main.
Events are delivered in publish order with stable ids, and a client reconnecting with Last-Event-ID receives what it missed within the retention bound.
An idle feed issues no periodic keyspace scan.
Retention of the event history is bounded and documented.
Design note: this feed is an append-only log. The fix must work on the stores NetScript supports today; it must not depend on Redis Streams, which the managed Garnet cache does not have yet.
Activity