c5te1n / node-red-contrib-dwd-local-weather

Node Red node to retrieve local weather forecast from DWD (Germany)
Apache License 2.0
13 stars 11 forks source link

UnhandledPromiseRejectionWarning #42

Open carsten-re opened 2 years ago

carsten-re commented 2 years ago

Hi,

I'm using node-red-contrib-dwd-local-weather 1.0.2 in Docker and I see some errors showing up:

(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: 13)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at runMicrotasks (<anonymous>)
(node:17) UnhandledPromiseRejectionWarning: ReferenceError: response is not defined
    at /data/node_modules/node-red-contrib-dwd-local-weather/dwdweather.js:92:28
(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: 11)
(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: 9)
(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: 7)

Should I be worried? Best Regards, Carsten

ei23fxg commented 2 years ago

Same here. It's caused NodeRED crashes on multiple of my installations. All at the same time ;-) So it must be caused by some serverside changes or issues (DWD) There is maybe some fix needed here, currently i had to delete all nodes.

forstran58 commented 2 years ago

As an emergency measure, I edited line 92 in /home/pi/.node-red/node_modules/node-red-contrib-dwd-local-weather/dwdweather.js, like: } else { reject("INVALD"); //reject(response.status + " " + response.statusText); }; (That is line 91 - 94 on my nodered installation.) Still no DWD data, but at least nodered does not crash, anymore.

carsten-re commented 2 years ago

...So it must be caused by some serverside changes or issues (DWD) There is maybe some fix needed here, currently i had to delete all nodes. Yeah, looks promising that that's the case. On this page (https://www.dwd.de/DE/leistungen/met_verfahren_mosmix/met_verfahren_mosmix.html) is a link that point to the Open Data Server. And that certificate expired yesterday at Sun, 08 May 2022 14:03:12 GMT.

carsten-re commented 2 years ago

The certificate on https://opendata.dwd.de/ is now replaced and the SSL issue is gone. NodeRed is able to get the values.

ei23fxg commented 2 years ago

But it should be catched and not cause a system to crash...

carsten-re commented 2 years ago

Ok, I have re-opened the issue. Let's see if it could be fixed.

ei23fxg commented 2 years ago

Ok, I have re-opened the issue. Let's see if it could be fixed.

In doubt some ugly try catch block should do it.

This is the uncatched error:

May 8 16:14:49 friday Node-RED[4198]: 8 May 16:14:49 - [red] Uncaught Exception: May 8 16:14:49 friday Node-RED[4198]: 8 May 16:14:49 - [error] ReferenceError: response is not defined May 8 16:14:49 friday Node-RED[4198]: at /home/user/.node-red/node_modules/node-red-contrib-dwd-local-weather/dwdweather.js:92:28 May 8 16:14:49 friday Node-RED[4198]: at runMicrotasks () May 8 16:14:49 friday Node-RED[4198]: at processTicksAndRejections (node:internal/process/task_queues:96:5) May 8 16:14:49 friday systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE May 8 16:14:50 friday systemd[1]: nodered.service: Failed with result 'exit-code'.

Edit: Ok I looked into it, it is just that a response never will be defined in the catch part. That has to be fixed. forstran58 already showed kind of the right solution.

c5te1n commented 2 years ago

Thanks for the error report, detailed analysis and suggested fix. I agree that the error handling needs to be more robust here and will fix this in the next version.