album-art
album-art copied to clipboard
Unhandled error event in case of malformed response
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?
Glad you got it working! I've very little time for updates so a PR is always greatly appreciated if you catch any errors 👍
Ok!
I'm gonna fix this a year+ later, any chance you remember reproduction steps?
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)
I see it now, great catch!