oeuillot / upnpserver

Fast and light upnp server for node
GNU General Public License v2.0
181 stars 47 forks source link

"Cannot read property 'album' of undefined" in musicRepository.js #58

Closed ajmas closed 8 years ago

ajmas commented 8 years ago

I get a failure when starting, which would be appear to be due to not testing for the error state in the callback for node.getAttributes():

/Users/ajmas/Development/musicserver/node_modules/upnpserver/lib/repositories/musicRepository.js:65
          var album = attributes.album || i18n.UNKNOWN_ALBUM;
                                ^

TypeError: Cannot read property 'album' of undefined
    at /Users/ajmas/Development/musicserver/node_modules/upnpserver/lib/repositories/musicRepository.js:65:33
    at null.<anonymous> (/Users/ajmas/Development/musicserver/node_modules/upnpserver/lib/node.js:615:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

The code should be changed such that:

       node.getAttributes(ContentDirectoryService.MED_PRIORITY, function(
            error, attributes) {

           if (error) { ... }

to avoid trying to access undefined attributes.

node 4.4.0, MacOS X 10.11.5, upnpserver 2.1.3

ajmas commented 8 years ago

Just seen that the 2.1.3 code base is really old and doesn't represent current head.