UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'codecName' of undefined
See original GitHub issueHi! Here is my code:
var streamaddr = 'url_to_http_stream';
http.get(streamaddr, (resp) => {
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
try
{
mm.parseBuffer(chunk, 'audio/ogg', { fileSize: 26838 })
.then( metadata => {
console.log(util.inspect(metadata, { showHidden: false, depth: null }));
});
}
catch (e)
{
}
});
}).on("error", (err) => {
//console.log("Error: " + err.message);
});
Seems it works, first part of data received is correct (tags array), but after 1 second appears this:
(node:25944) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘codecName’ of undefined at OggParser.<anonymous> (/path_to_project/node_modules/music-metadata/lib/ogg/OggParser.js:85:86) at Generator.next (<anonymous>) at fulfilled (/path_to_project/node_modules/music-metadata/lib/ogg/OggParser.js:4:58) at process._tickCallback (internal/process/next_tick.js:68:7) (node:25944) 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(). (rejection id: 2)
Am i wrong in my code or is it a bug?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
Yea, i figured it out, but you gave me an idea to convert src blob data to base64 in addition. Now it seems everything is working now, thanks again!
So regarding the conversion to HTML you can do something like this: https://github.com/Borewit/audio-tag-analyzer/blob/9b2cb3d702b663e03a7995a72520c8da011514af/src/app/app.component.html#L71
But maybe you already figured it out yourself.
The width and height are part of the metadata. These are the picture dimension as litterly written in metadata tag. 0 is close to not specified (ref), so yeah, you could say it may better not to define the
picture.width
property in such case.