ryanleesmith / homebridge-litter-robot-connect

Litter-Robot Connect Homebridge Plugin
MIT License
13 stars 3 forks source link

Litter Robot Accessories quit loading. #12

Closed aModernGirlMakes closed 3 years ago

aModernGirlMakes commented 4 years ago

This worked well for a while but now accessories are not loading. This is the error I see.

at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) (node:17106) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 378)

I am very new to homebridge and maybe this is obvious for what I should do.. but I don't know how to make the corrections. Thanks

apexad commented 3 years ago

Same error here. The accessories no longer show up. This plugin does not work at all anymore. I wonder if the API changed or they locked it down in some way.

apexad commented 3 years ago

So, @amodernstitch I was able to find a solution that I think will likely work for you too. In the Homebridge debug logs I was seeing this error:

Error syncing Litter-Robot Connect: [node-persist][readFile] /var/lib/homebridge/cache/litter-robot-platform/blahblahbalh does not look like a valid storage file!

On your homebridge server, run the command: rm -rf /var/lib/homebridge/cache/litter-robot-platform and then restart Homebridge and you should be good to go.

Not sure what is causing the node-persist cache to malfunction like this, but this seems to be a decent troubleshooting step to resolve it.

ryanleesmith commented 3 years ago

Sorry for not responding. I must not have notifications setup. I never encountered this error - did you upgrade anything else around the same time, either node, homebridge, or otherwise?

apexad commented 3 years ago

@ryanleesmith I realized too that my command above did not include the rm -rf part. Fixed that. I don't think this is an issue with your plugin per se, but rather the node-persist cache. Indeed, it may be due to a homebridge upgrade, or even as as simple as a restart at the wrong time.

ryanleesmith commented 3 years ago

Yea, I figured removing the files entirely would fix it. The node-persist plugin seems quite finicky. I have been able to reproduce the error by emptying the contents of the files it creates, and made some progress on catching the error in certain scenarios...but there is one that is still lingering that I can't quite catch or explain. I'm still playing around with it locally to pinpoint the error...if I can find the cause, I should be able to catch the exception and just ignore (the files are purely an optimization technique to avoid logging in on every request).

ryanleesmith commented 3 years ago

Ok, found the cause (uncaught exception within the plugin itself). I found a way to avoid it though - just need to test that out and cleanup the new error handling code which I will include anyways to hopefully prevent future issues.

ryanleesmith commented 3 years ago

Released 1.1.3 which should resolve most issues around corrupted/empty files. If permissions somehow change on the files after creation (or if you change the user that Homebridge runs as after running it previously with this plugin), I think that will still cause it to get stuck. That will take more work to try and not depend on the cache at all, but I also don't want to hit the login endpoint more frequently than needed, since the API is technically unsupported - so it's not something I really want to change anyways.

Hopefully this resolves (or would have resolved) your particular scenario.

ryanleesmith commented 3 years ago

One last note, I may just remove the cache/node-persist plugin entirely. It really doesn't offer a great benefit at this point, considering the cost of the errors/exceptions.