open-webui/backend/open_webui
Claude 1964c39ac1
fix(stream): disjoint key namespaces, O(N) fence drain
- Seq key moved from `{prefix}:stream:{user}:{msg}:seq` to
  `{prefix}:streamseq:{user}:{msg}`. A message_id containing a literal
  `:seq` suffix would otherwise make its stream key equal to another
  message's seq key, which under a user-controlled message_id would
  collide INCR against an XADD on the same Redis key.

- clearResumeFence swap-and-iterate instead of shift() in a loop.
  Array.shift is O(n) per call, so the old drain was O(n²). Practical
  frame counts during a fence window are small (dozens worst-case) so
  this was never a user-visible problem, but the fix is two lines and
  removes a Big-O footgun. Concurrency behavior unchanged: the batch
  is captured via reference-swap so frames arriving during an await
  continue buffering into the fresh empty array still present in the
  map, and the outer while loop drains those in the next iteration.

Not addressed:
- Concurrent-emitter out-of-seq live frames — already documented as a
  known limitation with a block comment at get_event_emitter; fix
  requires distributed locking.
- Prune resumeSeqByMessageId on per-message terminal events —
  deliberately removed two rounds ago because it caused continuation-
  reuses-message_id to replay duplicate content; the trade-off
  (bounded int-per-message memory vs. correctness) is already
  captured in that commit message.
2026-04-15 07:24:45 +00:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac 2026-04-12 19:41:02 -05:00
migrations refac 2026-04-01 18:26:46 -05:00
models refac 2026-04-13 21:29:03 -05:00
retrieval fix(retrieval): offload Loader.load to a worker thread so file uploads stop blocking the event loop (#23705) 2026-04-14 10:55:46 -05:00
routers fix(retrieval): offload Loader.load to a worker thread so file uploads stop blocking the event loop (#23705) 2026-04-14 10:55:46 -05:00
socket fix(stream): disjoint key namespaces, O(N) fence drain 2026-04-15 07:24:45 +00:00
static refac 2026-03-23 23:39:52 -05:00
storage refac 2026-04-12 19:08:30 -05:00
test refac 2026-03-17 17:58:01 -05:00
tools fix(retrieval): offload sync VECTOR_DB_CLIENT calls in async paths via AsyncVectorDBClient (#23706) 2026-04-14 10:50:18 -05:00
utils refac 2026-04-14 10:55:11 -05:00
__init__.py refac (#22987) 2026-03-24 15:41:26 -05:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-04-14 00:07:50 -05:00
constants.py refac 2026-04-13 14:08:58 -05:00
env.py refac 2026-04-13 16:25:44 -05:00
functions.py refac: async db 2026-04-12 14:22:11 -05:00
main.py fix(middleware): replace BaseHTTPMiddleware HTTP middlewares with pure ASGI implementations (#23709) 2026-04-14 10:47:48 -05:00
tasks.py refac 2026-03-17 17:58:01 -05:00