Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
thomst08 opened this issue Jun 8, 2024 · 8 comments
Closed
4 tasks done
Labels
🐛 Bug Something isn't working

Comments

@thomst08
Copy link

thomst08 commented Jun 8, 2024

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

  • Setup the same container and settings on a Windows system and Debian 12 system (two separate machines) with no issues found and the weather widget working.
  • Setup local dev environments locally on a Windows system and Debian 12 system with no issues found and the weather widget working.
  • Checked the server could make requests to the external API used to fetch the weather data with no issues found and receiving the expected JSON response.
  • Setup a local dev environment on the affected server and found the same issue was occurring locally on the system and not isolated to the docker container.
  • Tweaked packages, including updating next and trpc packages, no change with issue still occurring
  • Change the weather api call to call another external API before with no issues and returning the respected data from that API, but then failing on the call to geocoding-api.open-meteo.com
  • Setup a try/catch to grab the failing error on the API, finding the following:
Name: TypeError
Message: fetch failed
Cause: AggregateError
Stack: TypeError: fetch failed
    at Object.fetch (/app/homarr/node_modules/next/dist/compiled/undici/index.js:1:26669)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetchCity (/app/homarr/.next/server/chunks/5025.js:7566:21)
    at async resolveMiddleware (file:///app/homarr/node_modules/@trpc/server/dist/index.mjs:420:30)
    at async callRecursive (file:///app/homarr/node_modules/@trpc/server/dist/index.mjs:456:32)
    at async outputMiddleware (file:///app/homarr/node_modules/@trpc/server/dist/index.mjs:301:24)
    at async callRecursive (file:///app/homarr/node_modules/@trpc/server/dist/index.mjs:456:32)
    at async callRecursive (file:///app/homarr/node_modules/@trpc/server/dist/index.mjs:456:32)
    at async callRecursive (file:///app/homarr/node_modules/@trpc/server/dist/index.mjs:456:32)
    at async resolve (file:///app/homarr/node_modules/@trpc/server/dist/index.mjs:486:24)

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

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

  • I confirm that I attached the proper logs
  • I've read the docs
  • I've checked for duplicate issues
  • I've tried to debug myself
@thomst08 thomst08 added the 🐛 Bug Something isn't working label Jun 8, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Homarr Kanban Jun 8, 2024
Copy link

github-actions bot commented Jun 8, 2024

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
Copy link
Author

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.

Copy link

github-actions bot commented Aug 9, 2024

Hello 👋, this issue has been open for 60 days without activity. We mark issues to help prioritise and close dead issues. Can you confirm that this issue is still relevant on the latest version? I'll remove the stale label as soon as there is further activity on this issue. Thank you 🙏

@github-actions github-actions bot added the Stale label Aug 9, 2024
@thomst08
Copy link
Author

As of 0.15.3, this issue is still present

@github-actions github-actions bot removed the Stale label Aug 10, 2024
@savisaar2
Copy link

I am experiencing this problem right now, it's frustrating and still no fix?

@manuel-rw
Copy link
Collaborator

Hi, as mentioned in #1993 , we are currently focusing on the development of the new version. Sorry that it takes longer for us to reply. Can you all confirm that you can retrieve https://geocoding-api.open-meteo.com/v1/search?name=Paris from your containers (not the host machine)?
Have you considered configuring the DNS server for the container? https://stackoverflow.com/a/41717827
Have you checked whether the dev branch resolves this issue? We did update the image there.
Thanks @thomst08 btw for debugging this. We've had similar issues in the past and it could be quite lickely that this is a Node.js issue.
Sorry for the inconnvinience.

@thomst08
Copy link
Author

Hey @manuel-rw,

Thanks for taking the time to look, no problems, take your time :)
If memory serves...

  • I did ping the domain in the container and was able to make an API call and it did return the correct JSON query inside the container.
  • I checked the DNS, as I was able to ping everything correctly and the same for the host machine, I didn't do too much here, however, I think I did test this.... I can try again, but from experience, I think I can rule this out as the issue, just not 100%

I have just pulled down the latest dev branch as a test on the server, looks to be working perfectly 👍
I then updated my active Homarr install and confirm the changes in the latest dev docker container are working perfectly fine :) I am able to use the weather widget as intended with no 500 errors.

Thank you very much for looking into the issue. This is solved for me.
Looking forward to version 1.0

@manuel-rw
Copy link
Collaborator

Closing, problem has been solved

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Homarr Kanban Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants