mirror of
https://github.com/open-webui/open-webui.git
synced 2026-02-24 12:11:56 +01:00
fix: resolve backend execution deadlock when syncing stats with cyclic chat history (#21681)
This commit is contained in:
@@ -91,8 +91,17 @@ def get_message_list(messages_map, message_id):
|
||||
|
||||
# Reconstruct the chain by following the parentId links
|
||||
message_list = []
|
||||
visited_message_ids = set()
|
||||
|
||||
while current_message:
|
||||
message_id = current_message.get("id")
|
||||
if message_id in visited_message_ids:
|
||||
# Cycle detected, break to prevent infinite loop
|
||||
break
|
||||
|
||||
if message_id is not None:
|
||||
visited_message_ids.add(message_id)
|
||||
|
||||
message_list.append(current_message)
|
||||
parent_id = current_message.get("parentId") # Use .get() for safety
|
||||
current_message = messages_map.get(parent_id) if parent_id else None
|
||||
|
||||
Reference in New Issue
Block a user