Characters disappear randomly using jupyter-collaboration

Hey there,

We are using JupyterLab with jupyter-collaboration and nbgitpuller in a JupyterHub environment. After launching JupyterLab, nbgitpuller pulls the latest changes from remote.

Now, we are facing the issue that, from time to time, some single characters in code and text cells disappear randomly. Unfortunately, we cannot reproduce the error, but it occurs for some of our users.
I just want to ask if some of you may also have faced this issue and have a solution to it.
I didn’t find anything weird in the logs. I also tried to debug the .jupyter_ystore.db to find some clues, but failed to parse the BLOB updates inside the database.

If you have some ideas, please let me know!

Edit: In one case, the logs are spammed with the following error (may be unrelated though):

[E 2026-11-04 08:53:40.926 ServerApp] Failed to write message	
    Traceback (most recent call last):	
      File "/opt/conda/lib/python3.13/site-packages/jupyter_server_ydoc/handlers.py", line 353, in send	
        self.write_message(message, binary=True)
        ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^	
      File "/opt/conda/lib/python3.13/site-packages/tornado/websocket.py", line 360, in write_message	
        raise WebSocketClosedError()	
    tornado.websocket.WebSocketClosedError

We ran into this exact symptom with jupyter-collaboration 4.x on a single-user Hub setup where nbgitpuller was syncing course files. Even when only one person has the notebook open, jupyter-collaboration routes all editor buffer state through the server-side Yjs room (jupyter_server_ydoc) backed by .jupyter_ystore.db while simultaneously polling the underlying file via file_poll_interval.

When the container filesystem has slight mtime jitter or nbgitpuller touches the working tree during an active keystroke burst, the server sees an out-of-band disk change and re-applies a document diff against the YDoc, which swallows the last few uncommitted characters from the client buffer.

If your students do not need multi-cursor real-time editing inside the same user pod, the cleanest fix is disabling collaborative file-watcher re-sync or removing jupyter-collaboration from single-user images. If you need RTC enabled, setting these two options in jupyter_server_config.py stops the background file-poll and SQLite YStore race:

c.YDocExtension.file_poll_interval = 0
c.SQLiteYStore.db_path = ":memory:"

Putting db_path = ":memory:" also avoids stale .jupyter_ystore.db state fighting with nbgitpuller on container restarts.