alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
317 stars 98 forks source link

Unexpected Crash #36

Closed benbit closed 12 years ago

benbit commented 12 years ago

is this ttapi related?

SyntaxError: Unexpected token U at Object.parse (native) at [object Object].onMessage (/node_modules/ttapi/bot.js:151:20) at [object Object].onmessage (/node_modules/ttapi/bot.js:412:46) at Array.0 (/node_modules/ttapi/websocket.js:308:30) at EventEmitter._tickCallback (node.js:192:40)

alaingilbert commented 12 years ago

Pretty hard to say with that minimum of informations.

Do you get it often ? Do you get it when the script just start ? What does the code look like ?

All I can say is that you get a "SyntaxError". So it's probably not related.

benbit commented 12 years ago

Happens randomly starting a few hours ago, happens to two different bots at the same time who's code hasn't been moded in a while.

it doesn't reference anything in my bot files i just am wondering

alaingilbert commented 12 years ago

After some research, it look like you received bad json. Can you replace the line 151 in bot.js

 var json = JSON.parse(data.substr(data.indexOf('{'), len));

by

try {
   var json = JSON.parse(data.substr(data.indexOf('{'), len));
} catch(err) {
   console.log('ERROR:', data, err);
   return;
}

And tell me what is the complete output when you'll get the error !?

benbit commented 12 years ago
net.js:453
  if (!this._handle) throw new Error('This socket is closed.');
                           ^
Error: This socket is closed.
    at Socket._write (net.js:453:28)
    at Socket.write (net.js:446:15)
    at [object Object].<anonymous> (/home/turntable/node_modules/ttapi/websocket.js:449:16)
    at [object Object]._send (/home/turntable/node_modules/ttapi/bot.js:289:12)
    at [object Object].updatePresence (/home/turntable/node_modules/ttapi/bot.js:318:9)
    at Timer.<anonymous> (/home/turntable/node_modules/ttapi/bot.js:137:47)
    at Timer.ontimeout (timers.js:223:14)