andreypopov / node-red-contrib-miio-roborock

Xioami Roborock node-red nodes
Apache License 2.0
32 stars 12 forks source link

Catch uncaught promises and retry connecting on failure #20

Closed murjam closed 3 years ago

murjam commented 3 years ago

The problem

When node-red starts up while the Miio Roborock is not connected to the network yet, it fails to connect to it even if it comes online after some time. This is what can be read from the node-red logs:

31 Dec 16:17:24 - [warn] [miio-roborock-server:Miio server] Miio Roborock Error: send ENETUNREACH 192.168.1.64:54321
(node:342) UnhandledPromiseRejectionWarning: Error: send ENETUNREACH 192.168.1.64:54321
    at SendWrap.afterSend [as oncomplete] (dgram.js:467:11)
(node:342) 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: 1)
(node:342) [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.

The solution