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

Module sometimes hangs after connectivity issues #193

Open
ioloie opened this issue Aug 30, 2022 · 3 comments · May be fixed by #194
Open

Module sometimes hangs after connectivity issues #193

ioloie opened this issue Aug 30, 2022 · 3 comments · May be fixed by #194

Comments

@ioloie
Copy link

ioloie commented Aug 30, 2022

I've noticed that sometimes the module will hang. Investigating the logs suggersts it may not be handling a network issue well:

[30.08.2022 14:56.17.256] [ERROR] [SPOTIFY - [redacted]] Failed to request API: /v1/me/player
[30.08.2022 14:56.17.262] [ERROR] [SPOTIFY - [redacted]] Invalid request
[30.08.2022 14:56.17.273] [ERROR] (node:26841) UnhandledPromiseRejectionWarning: TypeError: Cannot read properties of undefined (reading 'headers')
    at /[redacted]/modules/MMM-Spotify/Spotify.js:161:39
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
(Use `electron --trace-warnings ...` to show where the warning was created)
[30.08.2022 14:56.17.275] [ERROR] (node:26841) 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: 2)

The fix I have locally is to add optional chaining to the referenced line so that it doesn't throw the error:

-            if (typeof error.response.headers["retry-after"] !== "undefined") retryTimerInSeconds = error.response.headers["retry-after"]
+            if (typeof error.response?.headers["retry-after"] !== "undefined") retryTimerInSeconds = error.response.headers["retry-after"]

Happy to do a PR if you like.

@ioloie ioloie changed the title Module sometimes crashes after connectivity issues Module sometimes hangs after connectivity issues Aug 30, 2022
@skuethe
Copy link
Owner

skuethe commented Aug 30, 2022

Hey there, thank you for bringing this up.
Sure, looking forward for a PR

@ioloie ioloie linked a pull request Aug 31, 2022 that will close this issue
@ioloie
Copy link
Author

ioloie commented Sep 1, 2022

I've been running #194 locally for 2 days now without the issue re-occurring, vs. only managing a few hours beforehand so it looks to have resolved the issue.

@skuethe
Copy link
Owner

skuethe commented Sep 13, 2022

Hey @ioloie sorry to leave your PR hanging here for two weeks. I currently don't have much time to dedicate to this project.
On that note, I remembered that I did some changes on this part already at the beginning of the year.
Could you do me a favor and evaluate the disconnect behavior against the development branch?
See also the latest commit to that branch: 453481b

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

Successfully merging a pull request may close this issue.

2 participants