calzoneman / sync

Node.JS Server and JavaScript/HTML Client for synchronizing online media
Other
1.47k stars 232 forks source link

Partial Disconnect #210

Closed awused closed 11 years ago

awused commented 11 years ago

Earlier today I was properly synchronized with the room but chat didn't appear, and typing messages didn't work.

Not sure how to reproduce this, or even what happened. I suspect I disconnected and then didn't fully reconnect. Videos were properly synchronized and the playlist was kept updated. It's possible other things were broken but I only noticed the chat.

calzoneman commented 11 years ago

I don't think this is a client side issue, but sometimes channels crash (or certain parts do) because of uncaught exceptions. In particular, prior to this afternoon giving leader while the playlist is empty would partially crash a channel.

calzoneman commented 11 years ago

All channel-wide messages are sent through the same function, so there's no logical reason for a client to only receive some messages.

awused commented 11 years ago

I assumed the connection broke, I reconnected to the websocket, but not all the frames got sent properly when the connection was reinitialized.

An example where this would happen is if you sent a joinChannel but not a login it would result in me being in a room but not logged in, but I'd still appear to be logged in from before my disconnect.

Something like that is my guess anyway.

calzoneman commented 11 years ago

Well, the clientside attaches all of the listeners at once, so that's probably not the problem. The server sends channel messages through a socket.io room so it's quantized- you either receive all messages, or none (disconnected). There's no potential for a half-connected state on the server, and unless you get a weird exception that breaks the closure I don't really see how this could happen clientside.

awused commented 11 years ago

This kept happening and I finally got fed up and tracked it down. The issue is caused by double-loading JS (external or not) when reconnecting.

https://raw.github.com/Suwako/animu-cytube/master/document.js

If this runs twice it'll lead to infinite recursion which fails silently when it runs out of stack space. I can easily fix the javascript there, but you might want to prevent it from injecting javascript a second time upon reconnecting.

calzoneman commented 11 years ago

Oops!

External JS is currently checked to see if the URL changed before it is applied. Channel JS is not checked. I will look into it though.