josephg / ShareJS

Collaborative editing in any app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

msg.d or collection missing in req errors

devongovett opened this issue · comments

We're getting errors submitting ops somewhat frequently where msg.d or collection missing in req is logged on the server and an error is sent back to the client. I'm not sure what state the connection is getting into to hit this case, but my guess is that the client is removing msg.d and msg.c here because it is the same as was sent for a previous message, but for some reason the server doesn't have the previous values in memory.

I've seen this enough that I've started to just add those fields back at the socket layer before sending every message to ensure this case isn't hit. Any ideas on why this case might be hit would be appreciated. I'll keep looking to see if I can figure out when this happens, just wondered if anyone else had seen it before. Thanks!

I haven't seen this error on our servers... are you using browserchannel or something else?

We're using engine.io (polling with upgrade to websockets). I realized later that engine.io doesn't guarantee message arrival order, which may have caused this issue. I ended up adding a sequence id to all of the outgoing messages to guarantee the order, and I haven't seen this issue since. We also multiplex several protocols over the same socket, so this was fairly easy to add. IMO engine.io should handle this, but I guess it doesn't at this point (at least in polling mode).

Ugh that sounds about right.. If socket.io wasn't crap I wouldn't have written node-browserchannel in the first place.

Sockjs, websockets and browserchannel should all work fine. (For ws you'll need to find your own reconnect library though).