Hypfer / Valetudo

Cloud replacement for vacuum robots enabling local-only operation
https://valetudo.cloud
Apache License 2.0
6.72k stars 397 forks source link

valetudo fails on sendMessage() called immediately on cold start #259

Closed rand256 closed 4 years ago

rand256 commented 5 years ago

I wrote a small mod of Valetudo and came across this issue.

If you happen to call any function from /lib/miio/Vacuum.js that is using sendMessage early enough, like, straight in Valetudo.js, and this happens right after device was (re-)booted, then something definitely breaks and Valetudo stops responding to any requests which is based on sendMessage - for example, getting state from /api/current_status etc. Valetudo process is stuck at ~20% CPU usage in this case, but data from web interface still could be loaded: only sendMessage-based /api/ requests are kept in "pending..." state forever.

This issue however doesn't happen if Valetudo was manually restarted when the device is online for some time. It fails only if one is trying to send messages to the vacuum when it's just booted.

Probably it can't be encountered in current releases or master branch (since no messages are sent until user manually opens the web interface, which requires some time), but I believe it is worth finding and fixing since Valetudo seems just can't recover from this state itself if it managed to get into it somehow.

rand256 commented 5 years ago

At first I erroneously wrote the specific issue not directly connected to original Valetudo, but now I've rewritten it in more general form.

Hypfer commented 5 years ago

I'm guessing that the msgID is the culprit here. The whole logic around that isn't very nice anyways.

You could try adding logging to each increment of it and see what happens

Hypfer commented 4 years ago

Is this still an issue?

rand256 commented 4 years ago

Nope.