Skip to content

Commit 63624e5

Browse files
committed
Added more listeners, to prevent uncaught exceptions. See https://gist.github.com/615009 for uncaptured 'timeout' errors.
1 parent 1ee5285 commit 63624e5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/socket.io/client.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,17 @@ Client.prototype._onConnect = function(req, res){
8787
req.addListener('error', function(err){
8888
req.destroy && req.destroy();
8989
});
90-
if (res) res.addListener('error', function(err){
91-
res.destroy && res.destroy();
90+
req.addListener('timeout', function(err){
91+
req.destroy && req.destroy();
9292
});
93-
93+
if (res){
94+
res.addListener('error', function(err){
95+
res.destroy && res.destroy();
96+
});
97+
res.addListener('timeout', function(err){
98+
res.destroy && res.destroy();
99+
});
100+
}
94101
if (this._disconnectTimeout) clearTimeout(this._disconnectTimeout);
95102
}
96103
};

0 commit comments

Comments
 (0)