ypy-websocket
ypy-websocket copied to clipboard
PanicException('called `Option::unwrap()` on a `None` value')
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
Thanks for reporting @chwzr, yes a reproducible example would help a lot.
hi @davidbrochart thanks for the quick reply!
here is a repo to reproduce the bug:
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
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.