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

pyo3_runtime.PanicException: called Result::unwrap() on an Err value: UnexpectedValue #98

Open
assoly-lab opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@assoly-lab
Copy link

assoly-lab commented Jan 4, 2025

Description

am not really sure if this is a bug or a mistake by me.

i created a websocket consumer that broadcast received updates from the frontend (NextJS with tiptapJS and HocusPocus provider) to connected clients using the consumer example (django_channels_consumer.YjsConsumer).
inside receive function
this condition is always true since the first byte of the received payload is never 0 or 1, therefore the server Ydoc file stays empty.

if bytes_data[0] != YMessageType.SYNC:
            return

but when i try to apply the received payload directly to Doc,

self.ydoc.apply_update(bytes_data)

i get this error.

File "D:\WebDevelopement\PortfolioProjects\Collaboration Tool\BackEnd\venv\Lib\site-packages\pycrdt_websocket\django_channels_consumer.py", line 182, in receive
    self.ydoc.apply_update(bytes_data)
  File "D:\WebDevelopement\PortfolioProjects\Collaboration Tool\BackEnd\venv\Lib\site-packages\pycrdt\_doc.py", line 166, in apply_update
    self._doc.apply_update(txn._txn, update)
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: UnexpectedValue

am i doing something wrong, or is it that the received bytes need some processing before applied.

Reproduce

just apply the received bytes directly to ydoc

async def receive(self,text_data=None, bytes_data=None):
    if bytes_data is not None:
        self.ydoc.apply_update(bytes_data)
    

I can try to make an isolated repro if necessary.

@assoly-lab assoly-lab added the bug Something isn't working label Jan 4, 2025
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

1 participant