ajnart / homarr

Customizable browser's home page to interact with your homeserver's Docker containers (e.g. Sonarr/Radarr)
https://homarr.dev
MIT License
5.45k stars 252 forks source link

Weather widget failing to fetch form Server: Receives 500 Internal Server Error #2067

Open thomst08 opened 3 weeks ago

thomst08 commented 3 weeks ago

Environment

Docker

Version

0.15.3

Describe the problem

Hello, I have recently setup Homarr on my server in a docker container, all is working fine except for the weather widget... I have been trying to track down the issue but not found the root cause. Having the widget on screen causes the browser to preform a network request, this receives a 500 error and logs nothing in the containers logs. Only giving me an error in the browsers dev tools network tab.

Logs

Weather fetch request

URL: http://{server address}/api/trpc/weather.at?batch=1&input={"0":{"json":{"name":"Paris","latitude":48.85341,"longitude":2.3488}}}
Status: 500 Internal Server Error
Response JSON:
[{"error":{"json":{"message":"fetch failed","code":-32603,"data":{"code":"INTERNAL_SERVER_ERROR","httpStatus":500,"path":"weather.at","zodError":null}}}}]

Find City request

URL: http://{server address}/api/trpc/weather.findCity?batch=1&input=%7B%220%22%3A%7B%22json%22%3A%7B%22query%22%3A%22Paris%22%7D%7D%7D
Status: 500 Internal Server Error
Response JSON:
[{"error":{"json":{"message":"fetch failed","code":-32603,"data":{"code":"INTERNAL_SERVER_ERROR","httpStatus":500,"path":"weather.findCity","zodError":null}}}}]

Context

Notes and testing: I have tried to locate the issue and done the following things

ERROR ❌ tRPC failed on weather.findCity: [ { "code": "invalid_type", "expected": "array", "received": "undefined", "path": [ "results" ], "message": "This field is required" } ]


- This fails on ``const res = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${query})`` or line 65 in ``weather.ts`` [link](https://github.com/ajnart/homarr/blob/68ff84c85a721be274456328c1b590b30c952939/src/server/api/routers/weather.ts#L65)

At this point, I am not sure what else could be the issue and why it is only affecting the one system, hopefully this is helpful for any one else who has had a similar issue or has some knowledge on what it could be.
I don't know this is so much a bug with Homarr, but it could be an issue on NextJS or my system in a configuration causing this issue.
OS: Ubuntu Server 24.04
Homarr version: 0.15.3

### Please tick the boxes

- [X] I confirm that I attached the proper logs
- [X] I've read the [docs](https://github.com/ajnart/homarr#readme)
- [X] I've checked for [duplicate issues](https://github.com/ajnart/homarr/issues)
- [X] I've tried to debug myself
github-actions[bot] commented 3 weeks ago

Hi 👋. Thank you for submitting your first issue to Homarr. Please ensure that you've provided all nessesary information. You can use the three dots > Edit button to update your post with additional images and information. Depending on the current volume of requests, the team should get in conact with you shortly.

thomst08 commented 2 weeks ago

Hello, I have been trying to dig into why I am having this issue and found a fix. The docker container is running on node version 20.2.0, my server has been running with the latest LTS version (20.14.0). I found changing my node version to any 18 version resolved the issue. After changing the version and reinstalling the packages, the dev server run correctly and weather API calls work without fail.

This appears to be some kind of bug with node(?) and not an issue with Homarr, but might be something to know about and maybe any new changes in the future might help prevent or resolve this issue.

I hope this helps correct any issues for anyone else who experiences this.