Closed zanethefox closed 4 months ago
Looking at the code, without reproducing it myself, this does definitely look like a bug.
In the update(forecastDays, callback)
function in openweathermap.js, it tries to fetch the current forecast with the 2.5 API:
// Old api requires an extra call to get the forecast
if (this.api === "2.5")
{
this.getWeatherData(this.apiBaseURL + "/data/2.5/forecast", (error, result) =>
{
this.generateForecasts(weather, result["list"], result["city"]["timezone"], callback);
});
}
In the function getWeatherData()
, if there is a requestError
it calls the callback with a null
result object, aka callback(requestError);
Then when it tries to process the response:
this.generateForecasts(weather, result["list"], result["city"]["timezone"], callback);
it does not take into account that an error
may have occurred and the result
object is null
.
I have a fix that would handle this error gracefully, aka log it and move on.
Can I send you an updated openweathermap.js
file to test?
Hello,
I have the same issue that occasionally occurs on version 3.2.11
.
I would appreciate the update of the openweathermap.js
file to test !
Thank you!
Fixed and landed in #276
Are we able to close this now?
Hello thanks so much for the work! I missed the notifications unfortunately. Yes, we can close this now, thanks again!
Hello, I just noticed my Homebridge install crashed due to an Error with the plugin.
Below is a log, has anyone got this error before? I am also using the API 2.5.
Is it possible to catch this error and handle it gracefully so it doesn't cause the home bridge to crash?
[04/09/2023, 20:29:25] TypeError: Cannot read properties of undefined (reading 'list') at /var/lib/homebridge/node_modules/homebridge-weather-plus/apis/openweathermap.js:108:46 at Request._callback (/var/lib/homebridge/node_modules/homebridge-weather-plus/apis/openweathermap.js:406:5) at self.callback (/var/lib/homebridge/node_modules/homebridge-weather-plus/node_modules/request/request.js:185:22) at Request.emit (node:events:513:28) at Request.onRequestError (/var/lib/homebridge/node_modules/homebridge-weather-plus/node_modules/request/request.js:877:8) at ClientRequest.emit (node:events:513:28) at TLSSocket.socketErrorListener (node:_http_client:502:9) at TLSSocket.emit (node:events:513:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) [04/09/2023, 20:29:25] Got SIGTERM, shutting down Homebridge... [04/09/2023, 20:29:30] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null [04/09/2023, 20:29:35] [HB Supervisor] Restarting Homebridge... [04/09/2023, 20:29:35] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules --strict-plugin-resolution [04/09/2023, 20:29:35] [HB Supervisor] Started Homebridge v1.6.1 with PID: 9237