From 3827a1d2910284bd2325e8169068f685e53604ca Mon Sep 17 00:00:00 2001 From: Sven Horvath <226917856+svenhorvath@users.noreply.github.com> Date: Sun, 16 Aug 2026 22:27:20 +0200 Subject: [PATCH] fix: keep the pending note save when an update carries no content snapshot stop_item_tasks() ran unconditionally while create_task() only ran when the update carried data, so an update without a content snapshot cancelled the pending save without scheduling a replacement and the edits were never written. --- backend/open_webui/socket/main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/socket/main.py b/backend/open_webui/socket/main.py index 9224501767..d459adc4b3 100644 --- a/backend/open_webui/socket/main.py +++ b/backend/open_webui/socket/main.py @@ -802,11 +802,6 @@ async def yjs_document_update(sid, data): log.warning(f'User {user.get("id")} does not have write access to note {note_id}. Rejecting update.') return - try: - await stop_item_tasks(REDIS, document_id) - except Exception: - pass - user_id = data.get('user_id', sid) update = data['update'] # List of bytes from frontend @@ -834,6 +829,16 @@ async def yjs_document_update(sid, data): await document_save_handler(document_id, data.get('data', {}), user) if data.get('data'): + # Only drop the pending save when a new one takes its place. + # Updates without a content snapshot (the resync a client sends + # after rejoining a document) would otherwise cancel the pending + # save without scheduling a replacement, so the edits made just + # before the resync never reach the database. + try: + await stop_item_tasks(REDIS, document_id) + except Exception: + pass + await create_task(REDIS, debounced_save(), document_id) except Exception as e: