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

Unhandled error event in case of malformed response #8

Closed
volumio opened this issue Oct 10, 2017 · 5 comments
Closed

Unhandled error event in case of malformed response #8

volumio opened this issue Oct 10, 2017 · 5 comments

Comments

@volumio
Copy link

volumio commented Oct 10, 2017

I got a bug report signalling that the module does not properly handle malformed replies (or non json replies) from audioscrobbler server.

See:
Oct 10 16:29:07 volumio volumio[1088]: undefined:1
Oct 10 16:29:07 volumio volumio[1088]:
Oct 10 16:29:07 volumio volumio[1088]: ^
Oct 10 16:29:07 volumio volumio[1088]: SyntaxError: Unexpected token < in JSON at position 0
Oct 10 16:29:07 volumio volumio[1088]: at Object.parse (native)
Oct 10 16:29:07 volumio volumio[1088]: at IncomingMessage. (/volumio/node_modules/album-art/index.js:29:22)
Oct 10 16:29:07 volumio volumio[1088]: at emitNone (events.js:91:20)
Oct 10 16:29:07 volumio volumio[1088]: at IncomingMessage.emit (events.js:185:7)
Oct 10 16:29:07 volumio volumio[1088]: at endReadableNT (_stream_readable.js:974:12)
Oct 10 16:29:07 volumio volumio[1088]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
Oct 10 16:29:07 volumio volumio[1088]: at process._tickCallback (internal/process/next_tick.js:104:9)

Maybe a try catch in https://github.com/lacymorrow/album-art/blob/master/index.js#L30 would solve it?

@lacymorrow
Copy link
Owner

Glad you got it working! I've very little time for updates so a PR is always greatly appreciated if you catch any errors 👍

@volumio
Copy link
Author

volumio commented Oct 13, 2017

Ok!

@lacymorrow
Copy link
Owner

I'm gonna fix this a year+ later, any chance you remember reproduction steps?

@volumio
Copy link
Author

volumio commented Dec 10, 2018

IMHO it can still happen here: https://github.com/lacymorrow/album-art/blob/master/index.js#L63

To replicate simply mock the response with an invalid json format (for example a string)

@lacymorrow
Copy link
Owner

I see it now, great catch!

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

2 participants