jupyter-server / pycrdt-websocket

WebSocket Connector for pycrdt
https://jupyter-server.github.io/pycrdt-websocket
MIT License
14 stars 10 forks source link

[New Issue] When using pycrdt-websocket 0.13.1, file access in jupyterlab can hang #41

Open jzhang20133 opened 7 months ago

jzhang20133 commented 7 months ago

When using pycrdt-websocket 0.13.1, file access in jupyterlab can hang.

https://github.com/jupyter-server/pycrdt-websocket/assets/4554746/f044cfc9-eba3-4e7a-a3a8-efb10946beee

Error logs shows that when ystore.read() method is called before ystore db initialization finishes, it is waiting on an old Event created in __init__ method and ystore.start() method has assigned a new Event. And the old Event() is never set hence file access is blocked.

Error Logs:

[I 2024-05-02 11:10:30.558 ServerApp] Creating new notebook in /TestRTC2
[I 2024-05-02 11:10:30.988 ServerApp] Request for Y document 'TestRTC2/Untitled62.ipynb' with room ID: e6db9699-d261-481e-a188-d76652c290b8
[I 2024-05-02 11:10:31.329 YDocExtension] Creating FileLoader for: TestRTC2/Untitled62.ipynb
initialize ystore, self.db_initialized=<anyio._backends._asyncio.Event object at 0x7ff5a83355a0>
[I 2024-05-02 11:10:31.332 YDocExtension] Watching file: TestRTC2/Untitled62.ipynb
[I 2024-05-02 11:10:31.337 ServerApp] Initializing room json:notebook:e6db9699-d261-481e-a188-d76652c290b8
read data, self.db_initializer=<anyio._backends._asyncio.Event object at 0x7ff5a83355a0>
starting initialize db, self.db_initialized=<anyio._backends._asyncio.Event object at 0x7ff5a8335a80>
ended initialize db, self.db_initialized=<anyio._backends._asyncio.Event object at 0x7ff5a8335a80>

We can see that read data, self.db_initializer=<anyio._backends._asyncio.Event object at 0x7ff5a83355a0> is waiting on an old Event which is never set. Since after start method is called, self.db_initialized is replaced with a new Event.

starting initialize db, self.db_initialized=<anyio._backends._asyncio.Event object at 0x7ff5a8335a80>
ended initialize db, self.db_initialized=<anyio._backends._asyncio.Event object at 0x7ff5a8335a80>
welcome[bot] commented 7 months ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada: