$ the-wire · showcase
orjson SSE frame split and lazy debug logs land in Open WebUI
By RepoJournal · Filed · About Open WebUI
Two performance patches and a correctness fix land in Open WebUI, including a latent SSE corruption bug when ENABLE_ORJSON is set.
A correctness fix for the Valkey/orjson backend addresses a silent data-loss bug in streaming responses. orjson emits U+2028, U+2029, and U+0085 raw, and Python treats those as line boundaries, so a model output containing one can split a `data: {...}` SSE frame mid-stream. `utils/middleware.py` reassembles frames with `splitlines()`, so the delta is dropped with no error. This is a breaking change in behavior only for setups with `ENABLE_ORJSON` set; those setups should update to get the escaping fix. [1]
Performance work on the Valkey vector store and the logging path both target wasted work. The Valkey backend now serializes chunk metadata through `JSONCodec`, which selects orjson when `ENABLE_ORJSON` is set, instead of the stdlib path on every insert and parse. Since `metadata_json` is never matched as text, switching codecs is safe and faster. Meanwhile, `GLOBAL_LOG_LEVEL` defaults to INFO, so every `log.debug(...)` call builds its f-string message before being discarded. That happens at 187 call sites on every request, with the worst offender in `process_chat_payload`, which stringifies the whole request body including full conversation history once per chat completion. Debug log messages are now built lazily, so disabled debug logs cost nothing. [2][3]
Two small cleanups round out the set. A stray unused `json` import was removed from `models/chats.py`; the module only referenced SQL function names like `json_each` inside `text()` strings. And new pt-BR translations cover UI items added in recent releases, with a consistency pass over existing strings for grammar, tone, capitalization, and pluralization, preserving placeholders and hotkeys. No logic changes in the i18n effort. [4][5]
Action items
- → If you run Open WebUI with ENABLE_ORJSON set, update to include the line-separator escaping fix before relying on streaming output. open-webui/open-webui [immediate]
- → Review your Valkey vector store configuration to confirm ENABLE_ORJSON is set to gain the JSONCodec performance benefit. open-webui/open-webui [plan]
- → Monitor the next release for the lazy-debug-log change; no action required on your side. open-webui/open-webui [monitor]
References
- [1] fix: escape line separators in orjson output (#27819) ↗ open-webui/open-webui
- [2] perf: use the orjson codec for Valkey vector metadata (#27805) ↗ open-webui/open-webui
- [3] perf: build debug log messages lazily so disabled debug logs cost nothing ↗ open-webui/open-webui
- [4] chore: remove unused json import in models/chats.py (#27796) ↗ open-webui/open-webui
- [5] i18n: add pt-BR translations for newly added UI items and consistency pass ↗ open-webui/open-webui