SocketCluster/socketcluster-client

eventObject timeout has a timeout set when it's not expecting a response

gak10100 opened this issue · 0 comments

Inside the _processOutboundEvent event Objects are created and a timeout is set. The problem is that a timeout is set for event objects that aren't expecting a response.

eventNode.data = eventObject;
let ackTimeout = options.ackTimeout == null ? this.ackTimeout : options.ackTimeout;
eventObject.timeout = setTimeout(() => {
this._handleEventAckTimeout(eventObject, eventNode);
}, ackTimeout);
this._outboundBuffer.append(eventNode);

Inside the _flushOutboundBuffer function Event Objects are passed off to the transport object

AGClientSocket.prototype._flushOutboundBuffer = function () {
let currentNode = this._outboundBuffer.head;
let nextNode;
while (currentNode) {
nextNode = currentNode.next;
let eventObject = currentNode.data;
currentNode.detach();
this.transport.transmitObject(eventObject);
currentNode = nextNode;
}
};

but because the event object doesn't have a callback it doesn't add it to the callbackMap

https://github.com/SocketCluster/socketcluster-client/blob/f5514434f51369166de9e5dafba2f7da147fb93e/lib/transport.js#L373C10-L387

This can lead to the timeout to hang even after the client has disconnected.