LearnBoost/socket.io-client — pull request #469 by crickeys (2012-09-14 00:40:58+00:00)
Title: Allow option for disconnectSync timeout for browsers that support it

Personally I have to use xhr-polling because websockets still have a rising memory usage until I run out of memory.

When using xhr-polling I need to know when a visitor changes pages on the site so I use opts['sync disconnect on unload'] = true;

However, I've noticed that if the node server is having trouble keeping up or some network connection issue, then this unload function halts the browser (I think this is because the xhr request is sync, which it needs to be in order to reach the server).

I discovered that some browsers respect a timeout setting on an xhr object. So, this commit gives you a new option to set opts['sync disconnect timeout'] = 300; // ms

It defaults to 0, so it will have the same original behavior. Otherwise you can set a number in ms for the function to timeout if the server doesn't respond.