ypy-websocket icon indicating copy to clipboard operation
ypy-websocket copied to clipboard

PanicException('called `Option::unwrap()` on a `None` value')

Open chwzr opened this issue 3 years ago • 4 comments

When using a yjs-websocket server (https://github.com/yjs/y-websocket) the ypy-websocket provider does not sync properly:

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/yrs-0.11.1/src/block.rs:1073:54

Traceback (most recent call last):
  File "/root/yspine-client/.venv/lib/python3.10/site-packages/ypy_websocket/websocket_provider.py", line 34, in _run
    await process_sync_message(message[1:], self._ydoc, self._websocket, self.log)
  File "/root/yspine-client/.venv/lib/python3.10/site-packages/ypy_websocket/yutils.py", line 130, in process_sync_message
    Y.apply_update(ydoc, update)
pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value

Other yjs clients on the same server work fine. Please let me know if you need further details or something to reproduce.

Cheers, chwzr

chwzr avatar Nov 22 '22 08:11 chwzr

Thanks for reporting @chwzr, yes a reproducible example would help a lot.

davidbrochart avatar Nov 22 '22 09:11 davidbrochart

hi @davidbrochart thanks for the quick reply!

here is a repo to reproduce the bug:

https://github.com/chwzr/ypy-sync-issue

chwzr avatar Nov 22 '22 11:11 chwzr

Thanks a lot @chwzr, I could reproduce the issue. It happens when the ypy client receives a SYNC_STEP2 message from yjs, and could be linked to https://github.com/y-crdt/ypy/issues/94. cc @dmonad @Horusiath @Waidhoferj

davidbrochart avatar Nov 22 '22 17:11 davidbrochart

I saw this in the ypy drawing example: https://github.com/y-crdt/ypy/blob/792dc96c8a55052b9123f1620856b977234188cf/examples/drawing/client.py#L30

so i updated the put_updates function to look like this:

def put_updates(update_queue: asyncio.Queue, ydoc: Y.YDoc, event: Y.AfterTransactionEvent) -> None:
    update = event.get_update()
    if update != b'\x00\x00':
        update_queue.put_nowait(update)

this will fix it for me now, but resolving https://github.com/y-crdt/ypy/issues/94 would feel better, as even the Y.encode_state_vector function is producing empty updates.

chwzr avatar Nov 25 '22 09:11 chwzr