xat / chromecast-player

simple chromecast player
MIT License
99 stars 20 forks source link

session can be undefined #6

Closed JSteunou closed 9 years ago

JSteunou commented 9 years ago

I have this error a lot

JSteunou commented 9 years ago

Humm I had it with another tool of mine which had previous 0.2.0 chromecast-player. I was unable to reproduce the bug with the 0.2.0.

xat commented 9 years ago

Hmm, I think the callback should get invoked with an 'session not found'-error in that case.

JSteunou commented 9 years ago

Sure, I dont know well the internal of your library, it was easiest to me to show with an example what error I had and which trick saved me at the moment. But I'm not sure this is still relevant as I cannot reproduce it on 0.2.0.

I had one program with < 0.2.0 and one with 0.2.0. The first with old chromecast-player put it on a weird state if I launched 2 commands in a row, like described in #5 And the second show me this log each time I was using it when I though the 1st one crashed.

GET /javascripts/app.js 200 2.297 ms - 1391

/home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/api.js:119
    var sessionId = session.mediaSessionId;
                           ^
TypeError: Cannot read property 'mediaSessionId' of undefined
    at /home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/api.js:119:28
    at /home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/api.js:109:5
    at /home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/api.js:63:7
    at RequestResponseController.onmessage (/home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/node_modules/castv2-client/lib/controllers/request-response.js:27:7)
    at RequestResponseController.emit (events.js:117:20)
    at Channel.onmessage (/home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/node_modules/castv2-client/lib/controllers/controller.js:16:10)
    at Channel.emit (events.js:98:17)
    at Client.onmessage (/home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/node_modules/castv2-client/node_modules/castv2/lib/channel.js:23:10)
    at Client.emit (events.js:117:20)
    at PacketStreamWrapper.onpacket (/home/jsteunou/Git/castnow-webui/node_modules/chromecast-player/node_modules/castv2-client/node_modules/castv2/lib/client.js:79:10)
Program node ./bin/www exited with code 8

(lines number are +1 because I had some console.log to find out what's going on)

xat commented 9 years ago

Okay, I can't really tell you why this error occurs at the moment, but if you change your PR to if (!session) return cb(new Error('session not found')); I'll gladly merge it.

JSteunou commented 9 years ago

and done ;)

xat commented 9 years ago

thanks :)