hjdhjd / homebridge-myq

:car: myQ Liftmaster and Chamberlain Plugin for Homebridge https://github.com/nfarina/homebridge
Other
568 stars 44 forks source link

UnhandledPromiseRejectionWarning error #453

Closed tim-dow closed 3 years ago

tim-dow commented 3 years ago

Describe The Problem: After the plugin is initiated, there appears to be some issue during the authentication process with myQ (starting with "UnhandledPromiseRejectionWarning"), and the garage door does not show up as an accessory. The issue has been happening since this particular plugin was installed about a week ago (replacing an older myQ plugin). I've verified that the password is correct and the myQ app works, and I've deleted/reinstalled the plugin, but I'm feeling stuck at this point!

To Reproduce: The issue occurs at every startup.

Logs:

[8/2/2021, 10:55:21 AM] Loaded plugin: homebridge-myq@2.6.3
[8/2/2021, 10:55:21 AM] Registering platform 'homebridge-myq.myQ'
[8/2/2021, 10:55:21 AM] ---
[8/2/2021, 10:55:22 AM] [myQ] Initializing myQ platform...
[8/2/2021, 10:55:22 AM] [myQ] Initializing child bridge 0E:D8:ED:20:2E:3E
[8/2/2021, 10:55:23 AM] [homebridge-myq] Launched child bridge with PID 31752
[8/2/2021, 10:55:23 AM] Registering platform 'homebridge-myq.myQ'
[8/2/2021, 10:55:23 AM] [homebridge-myq] Loaded homebridge-myq v2.6.3 child bridge successfully
[8/2/2021, 10:55:23 AM] Loaded 0 cached accessories from cachedAccessories.0ED8ED202E3E.
Preparing Advertiser for 'homebridge-myq 549F' using bonjour-hap backend!
Starting to advertise 'homebridge-myq 549F' using bonjour-hap backend!
[8/2/2021, 10:55:23 AM] Homebridge v1.3.4 (homebridge-myq) is running on port 40266.
(node:31752) UnhandledPromiseRejectionWarning: FetchError: Premature close of server response while trying to fetch https://partner-identity.myq-cloud.com/api/Account/LoginWithEmail?returnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3DIOS_CGI_MYQ%26code_challenge%3DPFpOy-xBcVVhZDuW_nPKAhLLo7s6rZ9z7t3RvwmP19A%26code_challenge_method%3DS256%26redirect_uri%3Dcom.myqops%253A%252F%252Fios%26response_type%3Dcode%26scope%3DMyQ_Residential%2520offline_access
    at consumeBody (/usr/local/lib/node_modules/homebridge-myq/node_modules/node-fetch/src/body.js:229:9)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Response.text (/usr/local/lib/node_modules/homebridge-myq/node_modules/node-fetch/src/body.js:129:18)
    at myQApi.oauthLogin (/usr/local/lib/node_modules/homebridge-myq/src/myq-api.ts:139:22)
    at myQApi.getOAuthToken (/usr/local/lib/node_modules/homebridge-myq/src/myq-api.ts:214:16)
    at myQApi.acquireAccessToken (/usr/local/lib/node_modules/homebridge-myq/src/myq-api.ts:281:19)
    at myQApi.refreshAccessToken (/usr/local/lib/node_modules/homebridge-myq/src/myq-api.ts:323:14)
    at myQApi.refreshDevices (/usr/local/lib/node_modules/homebridge-myq/src/myq-api.ts:357:10)
    at myQPlatform.updateAccessories (/usr/local/lib/node_modules/homebridge-myq/src/myq-platform.ts:283:10)
    at /usr/local/lib/node_modules/homebridge-myq/src/myq-platform.ts:324:14
(node:31752) 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: 1)
(node:31752) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Homebridge Configuration:

{
    "email": "[my@email.com]",
    "password": "[mypassword]",
    "platform": "myQ",
    "_bridge": {
        "username": "0E:D8:ED:20:2E:3E",
        "port": 40266
    }
}

Screenshots:

Environment:

hjdhjd commented 3 years ago

Try uninstalling and reinstalling the plugin. Should do the trick. The issue is not in the plugin, but in another package. Uninstalling and reinstalling the plugin should force the installation of the correct package versions.

tim-dow commented 3 years ago

No luck after uninstalling and reinstalling, unfortunately...still getting the same error in the log. Is it possible to single out the offending package and maybe selectively reinstall it?

hjdhjd commented 3 years ago

Out of curiosity, how exactly are you uninstalling and reinstalling the plugin?

tim-dow commented 3 years ago

I've uninstalled in the UI via the plugins section (wrench icon, then Uninstall) as well as via command line (npm uninstall -g homebridge-myq). Installation was done both ways as well, and both ended with the same result.

hjdhjd commented 3 years ago

This error is occurring due to a change in a dependency we rely upon. I've made adjustments in v2.6.3 to ensure we use the most recent version that remains compatible with Homebridge. Somehow, your setup seems to be installing the most recent version of this dependency (node-fetch to be exact) rather than pulling the correct version.

You're going to need to troubleshoot why things are being installed the way they are on your system...I'm afraid I can't help you much more there. But that's the essence of the issue here. Another, less ideal option of course, is to run all this in a docker container which will give you an even more precise environment. There's a preconfigured docker environment available for Homebridge.

Best of luck! Report back if you get things going.

tim-dow commented 3 years ago

Thank you! I ended up uninstalling Node and reinstalling 14.17.4 from scratch, and that appears to have kicked everything into place. (At least once I fixed a subsequent permissions issue with the .homebridge directory that was causing hb-service to get stuck in a restart loop.)

I appreciate your help here and all of your work with this project!

github-actions[bot] commented 1 year ago

This issue is locked to prevent necroposting on closed issues. Please create a new issue for related support requests, bug reports, or feature suggestions.