fjs21 / homebridge-kumo

Control your Kumo cloud devices using Homebridge.
https://www.npmjs.com/package/homebridge-kumo
Apache License 2.0
35 stars 8 forks source link

FetchError: invalid json response body at https://geo-c.kumocloud.com/login reason: Unexpected end of JSON input #7

Closed heftyfunseeker closed 4 years ago

heftyfunseeker commented 4 years ago

Restarted homebridge and having trouble logging in now. I've been able to successfully login 1/4 times.

(node:12935)` UnhandledPromiseRejectionWarning: FetchError: invalid json response body at https://geo-c.kumocloud.com/login reason: Unexpected end of JSON input
    at /usr/lib/node_modules/homebridge-kumo/node_modules/node-fetch/lib/index.js:272:32
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at KumoApi.acquireSecurityToken (/usr/lib/node_modules/homebridge-kumo/src/kumo-api.ts:126:18)
    at KumoHomebridgePlatform.discoverDevices (/usr/lib/node_modules/homebridge-kumo/src/platform.ts:65:18)
(node:12935) 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: 2)
(node:12935) [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.
heftyfunseeker commented 4 years ago

Was able to login again. I find logging in with the kumo ios app pretty unreliable. I imagine we just need to gracefully handle the borked kumo response. Also, thank you very much for this plugin! I have the direct control flag on and it's working great :)

fjs21 commented 4 years ago

Thanks. I’ll see if I can catch that error to avoid that issue cropping up again. Cheers, Fraser

GitHubRR1867 commented 4 years ago

I think I'm having a similar issue here. In trying to debug my other temperature issue ( #6 ) - I'm finding I'm getting the same types of errors:

(node:20849) UnhandledPromiseRejectionWarning: InvalidCharacterError: at /usr/local/lib/node_modules/homebridge-kumo/node_modules/base-64/base64.js:23:36 at Object. (/usr/local/lib/node_modules/homebridge-kumo/node_modules/base-64/base64.js:165:2) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Module.require (internal/modules/cjs/loader.js:1019:19) at require (internal/modules/cjs/helpers.js:77:18) at Object. (/usr/local/lib/node_modules/homebridge-kumo/src/kumo-api.ts:6:1) at Module._compile (internal/modules/cjs/loader.js:1133:30) (node:20849) 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: 39) (node:20849) UnhandledPromiseRejectionWarning: InvalidCharacterError: at /usr/local/lib/node_modules/homebridge-kumo/node_modules/base-64/base64.js:23:36 at Object. (/usr/local/lib/node_modules/homebridge-kumo/node_modules/base-64/base64.js:165:2) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Module.require (internal/modules/cjs/loader.js:1019:19) at require (internal/modules/cjs/helpers.js:77:18) at Object. (/usr/local/lib/node_modules/homebridge-kumo/src/kumo-api.ts:6:1) at Module._compile (internal/modules/cjs/loader.js:1133:30)

fjs21 commented 4 years ago

Ok. So the original error that was triggered here by a malformed json response from the kumo server will now, hopefully be caught and just cause the plugin to fail gracefully (i.e. with appropriate log response).

at KumoApi.acquireSecurityToken (/usr/lib/node_modules/homebridge-kumo/src/kumo-api.ts:126:18)

Will be fixed in 1.2.2