Error in Garbage Collector
Hi,
Has anyone encountered this error:
TypeError: Cannot use 'in' operator to search for 'issued' in undefined, at Manager.garbageCollection (/node_modules/socket.io/lib/manager.js:1023:21)
I'm using a node js cluster with 3 servers with node.js, socket.io and redis-store
I know I can make a temporaly fix, but I would like to know why I'm getting this error
Thanks.
+1 any ideas? I'm getting the same error using Mongo Store
@nicoburghi how you fix it? I also encountered it. and why this issue is closed? Iam using latest version 0.9.17 but still encountered it
@nguyenvansutt I fix it by asking for undefined befone using the 'in' operator with handshake collection. I'm using socket.io 0.9.16, maybe this issue is fixed in newer versions (maybe versions greater than 1.0.0).
My fixed garbage collection function is like this:
Manager.prototype.garbageCollection = function () {
// clean up unused handshakes
var ids = Object.keys(this.handshaken)
, i = ids.length
, now = Date.now()
, handshake;
while (i--) {
handshake = this.handshaken[ids[i]];
if ((typeof handshake != "undefined") && (handshake != null) && ('issued' in handshake) && (now - handshake.issued) >= 3E4) {
this.onDisconnect(ids[i]);
}
}
ids = Object.keys(this.closed);
i = ids.length;
expire = this.get('close timeout') * 1000;
// clean up the closed sockets
while (i--) {
data = this.closed[ids[i]];
if ('issued' in data && (now - data.issued) >= expire) {
delete this.closed[ids[i]];
}
}