Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'YDocWebSocketHandler' object has no attribute 'room' #321

Open
martinRenou opened this issue Jul 2, 2024 · 9 comments
Open

'YDocWebSocketHandler' object has no attribute 'room' #321

martinRenou opened this issue Jul 2, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@martinRenou
Copy link
Member

I'm getting the following error with jupyter-collaboration 2.1.1:

    Traceback (most recent call last):
      File "/home/martin/micromamba/envs/jupytercad/lib/python3.12/site-packages/tornado/ioloop.py", line 750, in _run_callback
        ret = callback()
              ^^^^^^^^^^
      File "/home/martin/micromamba/envs/jupytercad/lib/python3.12/site-packages/tornado/websocket.py", line 640, in <lambda>
        self.stream.io_loop.add_future(result, lambda f: f.result())
                                                         ^^^^^^^^^^
      File "/home/martin/micromamba/envs/jupytercad/lib/python3.12/site-packages/jupyter_collaboration/handlers.py", line 286, in on_message
        changes = self.room.awareness.get_changes(message[1:])
                  ^^^^^^^^^
    AttributeError: 'YDocWebSocketHandler' object has no attribute 'room'
@martinRenou martinRenou added the bug Something isn't working label Jul 2, 2024
@davidbrochart
Copy link
Collaborator

Could you try updating to jupyter-collaboration v3.0.0.a2?

@martinRenou
Copy link
Member Author

When using jupyter-collaboration 3.0.0a2 I'm getting a front-end error when trying to open a file

Screenshot from 2024-07-02 11-37-29

@krassowski
Copy link
Member

krassowski commented Jul 16, 2024

Is this (the v3.0a2 issue) when opening a plain text file or when opening the CAD file?

@martinRenou
Copy link
Member Author

It was when opening a CAD file. We should try to upgrade jupyter collaboration there with the recent beta.

@krassowski
Copy link
Member

I can reproduce this exception when attempting to create a test notebook on main:

HTTPServerRequest(protocol='http', host='127.0.0.1:35807', method='GET', uri='/a%40b/api/collaboration/room/json:notebook:649151c4-1672-4ad7-83e6-a91a79e2e963?sessionId=fef3429c-4cff-4dcf-ac61-97cad81c2b8b', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/site-packages/tornado/web.py", line 1790, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/jupyter_collaboration/projects/jupyter-server-ydoc/jupyter_server_ydoc/handlers.py", line 210, in get
    return await super().get(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site-packages/tornado/websocket.py", line 273, in get
    await self.ws_connection.accept_connection(self)
  File "/site-packages/tornado/websocket.py", line 863, in accept_connection
    await self._accept_connection(handler)
  File "/site-packages/tornado/websocket.py", line 946, in _accept_connection
    await self._receive_frame_loop()
  File "/site-packages/tornado/websocket.py", line 1105, in _receive_frame_loop
    self.handler.on_ws_connection_close(self.close_code, self.close_reason)
  File "/site-packages/tornado/websocket.py", line 571, in on_ws_connection_close
    self.on_connection_close()
  File "/site-packages/tornado/websocket.py", line 563, in on_connection_close
    self.on_close()
  File "/jupyter_collaboration/projects/jupyter-server-ydoc/jupyter_server_ydoc/handlers.py", line 339, in on_close
    if isinstance(self.room, DocumentRoom) and self.room.clients == [self]:
                  ^^^^^^^^^
AttributeError: 'YDocWebSocketHandler' object has no attribute 'room'

This can be uncovered by adding the following pytest test:

@pytest.mark.parametrize("copy", [True, False])
async def test_get_document_notebook(rtc_create_notebook, jp_serverapp, copy):
    path, content = await rtc_create_notebook("test.ipynb", "test", store=True)
    collaboration = jp_serverapp.web_app.settings["jupyter_server_ydoc"]
    document = await collaboration.get_document(
        path=path, content_type="notebook", file_format="json", copy=copy
    )
    assert document.get() == content == "test"
    await collaboration.stop_extension()

@krassowski
Copy link
Member

Note that the content ("test") is not a valid notebook. If I replace it with

nb = nbformat.v4.new_notebook()
content = nbformat.writes(nb, version=4)

then it does not throw. It looks like exception handling may be off here.

@fperez
Copy link
Contributor

fperez commented Aug 22, 2024

Any progress on this? On a clean, fresh install of jupyterlab with python 3.12 with mambaforge, I basically can't open any existing notebooks as I get pages and pages of these errors. I had to uninstall the collab machinery entirely so I could at least get work done.

Given this is on a fully clean install on an otherwise empty system, I'm pretty concerned that it is likely to hit users very easily... And it's a hard blocker - nothing works, documents can't be opened, nor even closed: the UI hangs in a weird state.

@krassowski
Copy link
Member

krassowski commented Aug 22, 2024

As per my previous reply, I think this error message is a red herring. It is basically error which shows up when the connection closes if there is a different error which lead to the connection closure. The immediate action item is to expose the real error so that we can address potentially multiple underlying problems. Do you also see this on newly created notebooks or only on existing notebooks? If it is the latter, can you share such an existing notebook?

I do not experience the problem you are facing but none of the deployments I manage use Python 3.12, and I am using the bleeding edge beta of version 3. I hope that with version 3/JupyterLab 4.3 - also in beta - many bugs will be ironed out to make it production-ready (for now I would not advise trying the beta yet - unless you have patience to follow some workarounds that I can share - as there are known issues in works).

@martinRenou
Copy link
Member Author

martinRenou commented Aug 22, 2024

From using more RTC a bit more, I seem to be able to get a clean working setup when starting fresh and removing the .jupyter_ystore.db file at the location of the server. @fperez you may want to try removing that file and restarting the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants