question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'codecName' of undefined

See original GitHub issue

Hi! 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:closed
  • Created 5 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MaddyCrowlecommented, Mar 21, 2019

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!

0reactions
Borewitcommented, Mar 20, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'find' of undefined - Stack ...
find is in a bunch of places. So the error is telling you that the variable you are using is undefined.... so figure...
Read more >
TypeError: Cannot read property 'data' of undefined
to show where the warning was created) [0] (node:24430) UnhandledPromiseRejectionWarning: Unhandled promise rejection.
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
How to Fix TypeError: Cannot read Property 'push' of ...
let myArray = undefined; myArray.push("John Doe"); // Uncaught TypeError: Cannot read properties of undefined (reading 'push') ...
Read more >
How to Prevent the TypeError: Cannot Read Property Map of ...
A guide on the root cause of 'cannot read map of undefined' as well as techniques and tools to prevent this error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found