LearnBoost/engine.io — pull request #148 by roamm (2013-02-20 07:33:44+00:00)
Title: Reliability Improvements on Transport Tier

Firstly I'd like to say I don't run into any obvious bugs without these changes.

Because Socket has some implicit assumptions like:
1) never call this.transport.close() more than once;
2) never rely on 'close' event from the underlying transport for a forced close;
3) the polling transport can be in an 'opening' state even Socket has closed;
4) callback of transport.close() is not reentrant;
5) 'close' event (not triggered in current implementation) from the old transport will break the logic while upgrading;

These assumptions make the code kinda fragile so I took some time trying to fix it and hope this would help.