mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 19:38:46 -05:00
[PR #21648] [CLOSED] fix(Messages): graceful fallback when history.currentId points to an orphan node #26181
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21648
Author: @ephb
Created: 2/20/2026
Status: ❌ Closed
Base:
main← Head:fix/resilient-currentid-fallback📝 Commits (1)
1592ab3fix(Messages): graceful fallback when history.currentId is an orphan node📊 Changes
1 file changed (+34 additions, -10 deletions)
View changed files
📝
src/lib/components/chat/Messages.svelte(+34 -10)📄 Description
Closes / Related
Fixes #15189
Problem
When the browser closes (or the network drops) while OpenWebUI is generating follow-up questions, the backend writes a partial placeholder node into
history.messagesand updateshistory.currentIdto point at it — before the node hasrole,content,parentId, orchildrenIds.The resulting orphan looks like:
Messages.svelte's reactive block starts athistory.currentIdand walks backwards throughparentIdlinks to build the message list. Starting from a node with norolemeans the walk finds nothing valid, so the component emitsmessages = []on every tick — the chat shows an infinite spinner and never loads, even after hours. No console errors appear, making this hard to diagnose.This is the exact scenario reported in #15189 (and confirmed in the wild on our own deployment with a second independently-encountered instance).
Fix
Before starting the tree-walk, validate that
history.currentIdresolves to a message that has aroleproperty. If it does not, find the most recent valid terminal message (hasrole,childrenIdsis an empty array) sorted by timestamp, and use that as the starting point instead.A
console.warnis emitted so the fallback is visible in DevTools without breaking the UX. If no valid terminal message exists at all, aconsole.erroris emitted and the chat renders empty (same behavior as before, but without the infinite reactive loop).How to reproduce
Or, inject an orphan manually into the DB (see issue #15189 for a ready-made JSON import that reliably triggers it).
Testing
v0.8.3-baseline, unmodified): chat spins forever.v0.8.3-resilient, this patch): chat loads, browser console shows theconsole.warnfallback message, zero errors.Scope
Single file changed:
src/lib/components/chat/Messages.svelte(+34 / -10 lines). No backend changes, no new dependencies.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.