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

UnhandledPromiseRejectionWarning #57

Open
p4mr opened this issue Apr 19, 2024 · 6 comments
Open

UnhandledPromiseRejectionWarning #57

p4mr opened this issue Apr 19, 2024 · 6 comments

Comments

@p4mr
Copy link

p4mr commented Apr 19, 2024

Just updated MM to version 2.27.0, and discovered MMM-AirQuality no longer loads (data is stuck on Loading.....)

Running PM2 Log gives the below error trace

0|mm | [2024-04-19 12:28:11.472] [ERROR] (node:1100) UnhandledPromiseRejectionWarning: TypeError: fetch failed
0|mm | at Object.fetch (node:internal/deps/undici/undici:12293:11)
0|mm | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|mm | at async Class.loadData (/home/mirror/MagicMirror/modules/MMM-AirQuality/helper.js:21:20)
0|mm | (Use electron --trace-warnings ... to show where the warning was created)
0|mm | [2024-04-19 12:28:11.477] [ERROR] (node:1100) 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: 1)

@NashJames
Copy link

I've had this error for a while and just now looked into it. Seems a breaking bug was introduced by a node dependency and no fix has been released yet. You can follow the progress here

Alternatively, I've lowered my node version to v18, which uses a version of the dependency before the bug was introduced. This has fixed the issue for me so you can do that in the meantime. If you don't have it, I recommend installing nvm to make switching node versions easy

@uros76
Copy link

uros76 commented Jun 10, 2024

@NashJames hi. Which exact version of node works? I tried with v18.20.3 and no good. I get the same problem as mentioned in the above post. I also tried v18.0.0 and it doesn't help.

@NashJames
Copy link

@uros76 After trying again myself, it seems that this fixed some of my instances of the mirror and not others (they have differing project and module versions). It's possible I've missed something in the nodejs codebase.

According to this comment, they should release a proper fix with node v20.14.1. I plan to wait another 2 weeks and see if that resolves it. If not, an alternate rest library like got (which doesn't rely on fetch) might be the answer.

@ivanovd
Copy link

ivanovd commented Jan 21, 2025

Did anyone got it working? I am on node v22.13.0 and get the same error.

@uros76
Copy link

uros76 commented Jan 21, 2025

I gave up on this module and feed the AQI data from my smart home HomeAssistant.

@NashJames
Copy link

You won't be able to get this module working unless you downgrade magicmirror to v2.26.0; which would then require you to downgrade a number of other modules.

It will work in headless mode (npm run server) if you have any up-to-date version of NodeJS LTS installed; but this won't suit most people.

For anyone curious, NodeJS released a bug for the fetch API which they promptly resolved. Unfortunately, electron bundled this broken version of NodeJS into their releases which MagicMirror began using in the release following the one listed above. I wouldn't expect an update from Electron or MagicMirror with a fix soon.

To be clear it's not the maintainers fault; though a comment in the README summarising this would be useful for anyone considering using the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants