TheAgentK / tuya-mqtt

Nodejs-Script to combine tuyaapi and openhab via mqtt
MIT License
173 stars 81 forks source link

tuya-mqtt crushing #87

Closed JacekKac closed 3 months ago

JacekKac commented 3 months ago

i notitced that my tuya-mqtt instance is crashing when a power outgage turns off my devices. Devices after a while are back online in tuya cloud, but the problem in tuya-mqtt is still active, need to restart app to get it back working again. Any clues how to solve this problem? devices.conf:

[  {
    name: 'Curtain Motor 2',
    id: 'bf7dabfd______e2a2ukhc',
    key: '_____________'
  },
  {
    name: 'Curtain Motor',
    id: 'bff88_____a5c63dcednlg0',
    key: '________'
  }
]
Mar 04 08:02:03 home node[477]:     at Socket._onTimeout (net.js:495:8)
Mar 04 08:02:03 home node[477]:     at listOnTimeout (internal/timers.js:557:17)
Mar 04 08:02:03 home node[477]:     at processTimers (internal/timers.js:500:7)
Mar 04 08:02:03 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async f>
Mar 04 08:02:03 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Error: connection timed out
Mar 04 08:02:03 home node[477]:     at Socket.<anonymous> (/etc/openhab/scripts/tuya-mqtt/node_modules/tuyapi/index.js:349:18)
Mar 04 08:02:03 home node[477]:     at Object.onceWrapper (events.js:519:28)
Mar 04 08:02:03 home node[477]:     at Socket.emit (events.js:400:28)
Mar 04 08:02:03 home node[477]:     at Socket._onTimeout (net.js:495:8)
Mar 04 08:02:03 home node[477]:     at listOnTimeout (internal/timers.js:557:17)
Mar 04 08:02:03 home node[477]:     at processTimers (internal/timers.js:500:7)
Mar 04 08:02:03 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async f>
Mar 04 17:29:58 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Error: connection timed out
Mar 04 17:29:58 home node[477]:     at Socket.<anonymous> (/etc/openhab/scripts/tuya-mqtt/node_modules/tuyapi/index.js:349:18)
Mar 04 17:29:58 home node[477]:     at Object.onceWrapper (events.js:519:28)
Mar 04 17:29:58 home node[477]:     at Socket.emit (events.js:400:28)
Mar 04 17:29:58 home node[477]:     at Socket._onTimeout (net.js:495:8)
Mar 04 17:29:58 home node[477]:     at listOnTimeout (internal/timers.js:557:17)
Mar 04 17:29:58 home node[477]:     at processTimers (internal/timers.js:500:7)
Mar 04 17:29:58 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async f>
Mar 07 08:02:00 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Error: connection timed out
Mar 07 08:02:00 home node[477]:     at Socket.<anonymous> (/etc/openhab/scripts/tuya-mqtt/node_modules/tuyapi/index.js:349:18)
Mar 07 08:02:00 home node[477]:     at Object.onceWrapper (events.js:519:28)
Mar 07 08:02:00 home node[477]:     at Socket.emit (events.js:400:28)
Mar 07 08:02:00 home node[477]:     at Socket._onTimeout (net.js:495:8)
Mar 07 08:02:00 home node[477]:     at listOnTimeout (internal/timers.js:557:17)
Mar 07 08:02:00 home node[477]:     at processTimers (internal/timers.js:500:7)
Mar 07 08:02:00 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async f>
Mar 07 09:03:03 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Error: connection timed out
Mar 07 09:03:03 home node[477]:     at Socket.<anonymous> (/etc/openhab/scripts/tuya-mqtt/node_modules/tuyapi/index.js:349:18)
Mar 07 09:03:03 home node[477]:     at Object.onceWrapper (events.js:519:28)
Mar 07 09:03:03 home node[477]:     at Socket.emit (events.js:400:28)
Mar 07 09:03:03 home node[477]:     at Socket._onTimeout (net.js:495:8)
Mar 07 09:03:03 home node[477]:     at listOnTimeout (internal/timers.js:557:17)
Mar 07 09:03:03 home node[477]:     at processTimers (internal/timers.js:500:7)
Mar 07 09:03:03 home node[477]: (node:477) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async f>
Mar 08 17:37:28 home systemd[1]: Stopping tuya-mqtt...
Mar 08 17:37:30 home systemd[1]: tuya-mqtt.service: Succeeded.
Mar 08 17:37:30 home systemd[1]: Stopped tuya-mqtt.
Mar 08 17:37:30 home systemd[1]: tuya-mqtt.service: Consumed 5min 17.173s CPU time.
tsightler commented 3 months ago

As this project has been unmaintained for almost 4 years, there's little chance such an issue will be addressed, I'm sure there are many cases of unhandled promise rejections that can occur. Most likely these have been there forever, but NodeJS versions prior to v15 only threw a warning while modern versions default to throwing an error which will cause the process to exit.

However, it is possible to use the --unhandled-rejections=warn parameter on NodeJS to revert it to a warning as it was in previous versions. This should at least keep the process from exiting.