stefanw / channels-yroom

Django Channels WebSocket consumer and worker for synchronizing Yjs clients
https://channels-yroom.readthedocs.io/en/latest/
MIT License
15 stars 5 forks source link

For some reason, after a while the worker crashes and/or it crashes after some error. #9

Closed linspw closed 1 year ago

linspw commented 1 year ago

For some reason, after a while the worker crashes and/or it crashes after some error.

I noticed that sometimes this happens, because there was an error, and the worker stopped responding after this error.

For example:

class YDocUpdateManager(models.Manager):
    def get_snapshot(self, name):
        try:
            data = self.get(name=name).data
            return bytes(None) # <<<<<<<
        except YDocUpdate.DoesNotExist:
            return None

    def save_snapshot(self, name, data):
        return self.update_or_create(name=name, defaults={"data": data})

This also happens when the active worker spends some time, I imagine that it is an error that happened and it is holding the response due to asyncronism.

Note: I already adjusted for the new update


I've been following each Update and I'm finding your project amazing. Thank you for your attention and initiative!

linspw commented 1 year ago

I'll turn on the logs to better understand what step it's crashing at.

But most likely the errors are popping silently.

linspw commented 1 year ago

I think that's it, error + solution:

https://stackoverflow.com/questions/43207927/how-to-shutdown-the-loop-and-print-error-if-coroutine-raised-an-exception-with-a

linspw commented 1 year ago

After this log step, he stopped receiving messages and logging.

Most likely got the silent error on get_snapshot

Captura de tela de 2023-05-16 15-41-15

linspw commented 1 year ago

https://github.com/stefanw/channels-yroom/pull/10

linspw commented 1 year ago

I already solved it by dealing inline with the error.

The get snapshot problem was on my side.

Feel free, if you want to leave the Issue open about the silent errors or if you think it's better to close it.

stefanw commented 1 year ago

Thanks. Better visibility into errors is definitely helpful to detect misconfiguration or other bugs. I‘ll merge in #11 after some tests.

linspw commented 1 year ago

Thank you very much and congratulations again for the work.

I just updated and so far it's working perfectly!