From 7c207327e303a6549918f538023a2f285a2a7232 Mon Sep 17 00:00:00 2001 From: QuantumGhost Date: Tue, 24 Mar 2026 22:28:54 +0800 Subject: [PATCH] fix(api): StreamsBroadcastChannel start reading messages from the end Setting initial `_last_id` to `0-0` would causing every subscription to receive one copy of the event stream, which is not compatible with the current frontend / backend communication protocol. --- api/libs/broadcast_channel/redis/streams_channel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/libs/broadcast_channel/redis/streams_channel.py b/api/libs/broadcast_channel/redis/streams_channel.py index d6ec5504ca..aaeaf76f7b 100644 --- a/api/libs/broadcast_channel/redis/streams_channel.py +++ b/api/libs/broadcast_channel/redis/streams_channel.py @@ -64,7 +64,10 @@ class _StreamsSubscription(Subscription): self._client = client self._key = key self._closed = threading.Event() - self._last_id = "0-0" + # Setting initial last id to `$` to signal redis that we only want new messages. + # + # ref: https://redis.io/docs/latest/commands/xread/#the-special--id + self._last_id = "$" self._queue: queue.Queue[object] = queue.Queue() self._start_lock = threading.Lock() self._listener: threading.Thread | None = None