codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.06k stars 339 forks source link

UnhandledPromiseRejectionWarning: Error: resolveIds() timed out #109

Closed mikepikefl closed 5 years ago

mikepikefl commented 5 years ago

When my Smart Plugs are off I receive the following unhandled exception warning. Everything appears to work fine but it seems the code should handle this exception.

[11/11/2018, 12:06:46 PM] [TuyaPlatform] Adding: Smart Plug X (generic / Y)
(node:711) UnhandledPromiseRejectionWarning: Error: resolveIds() timed out. Is the device powered on and the ID correct?
    at timeout (/home/homebridge/.nvm/versions/node/v10.13.0/lib/node_modules/homebridge-tuya/node_modules/tuyapi/index.js:143:22)
    at Timeout.setTimeout [as _onTimeout] (/home/homebridge/.nvm/versions/node/v10.13.0/lib/node_modules/homebridge-tuya/node_modules/p-timeout/index.js:19:13)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:711) 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(). (rejection id: 4)
codetheweb commented 5 years ago

Hmm, the error should be caught. What version of homebridge-tuya do you have installed?

mikepikefl commented 5 years ago

"npm view" shows homebridge-tuya@0.3.1

codetheweb commented 5 years ago

After some more investigation, it appears it's a bug in TuyAPI. Thanks for the report.

codetheweb commented 5 years ago

Fixed in tuyapi@3.1.4 and homebridge-tuya@0.3.2. Please try updating the Homebridge plugin and see if it works now.

mikepikefl commented 5 years ago

Awesome, thanks! Works great after updating.

codetheweb commented 5 years ago

👍