Foddy / node-red-contrib-huemagic

Philips Hue node to control bridges, lights, groups, motion sensors, temperature sensors and Lux sensors using Node-RED.
https://flows.nodered.org/node/node-red-contrib-huemagic
Apache License 2.0
200 stars 67 forks source link

Error 'Cannot read property 'status' of undefined' on console makes HUEMagic unresponsive #363

Closed FredBlo closed 2 years ago

FredBlo commented 2 years ago

Describe the bug Error 'Cannot read property 'status' of undefined' is displayed on the console when node-red is running for a few days. It does not crash node-red but all HUE related flows become unreactive (i.e. pressing a HUE switch button will not start the related flow)

Console log : (node:17) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'status' of undefined at /data/node_modules/node-red-contrib-huemagic/huemagic/utils/api.js:102:37 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:95:5) (Use node --trace-warnings ... to show where the warning was created) (node:17) 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:17) [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.

Flow to Reproduce (this is not specifically related to a single flow)

Expected behavior manage the 'undefined' in such a case

Screenshots n.a.

Please complete the following information:

Additional context Add any other context about the problem here.

ptweety commented 2 years ago

Hi @FredBlo, I think this is related to a fix #349 that has been merged but not yet included in the current 4.2.2 release.

FredBlo commented 2 years ago

Hi @ptweety ,

Thanks for your answer. Is seems linked indeed, I did not find this one (and did also not know v4.2.2 was not the latest main code actually). Will re-test it as soon as new version which includes this merge is released then

FredBlo commented 2 years ago

Hi @ptweety ,

I applied to changes you mentionned manually on my install. It works now fine for >10 days without any such issue occurring again. Thanks for it !

@Foddy : seems fix #349 already merged is OK for release to npm thus :-)

ordisimon commented 2 years ago

Hi @ptweety ,

I applied to changes you mentionned manually on my install. It works now fine for >10 days without any such issue occurring again. Thanks for it !

@Foddy : seems fix #349 already merged is OK for release to npm thus :-)

Hi :-) great thanks for this encouraging feedback is it complicated to apply this change ? i'm on raspberry pi os

thanks

FredBlo commented 2 years ago

Hi @ptweety , I applied to changes you mentionned manually on my install. It works now fine for >10 days without any such issue occurring again. Thanks for it ! @Foddy : seems fix #349 already merged is OK for release to npm thus :-)

Hi :-) great thanks for this encouraging feedback is it complicated to apply this change ? i'm on raspberry pi os

thanks

@ordisimon : you need to get access to the files on your raspberry and update the file in node-red\node_modules\node-red-contrib-huemagic. Either using the way you edit files on your Raspberry (or using SSH connection to it ?)... Just be aware any npm update (updating another module for example) will replace your updated files with the 'officially' published ones, meaning you have to adapt it again after any update...