Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed handling callback after connection has been closed

  • Loading branch information...
commit 92e968e40b6d29034b786ebcdc9dcda5f62e7587 1 parent 52f71db
@zerodivisi0n zerodivisi0n authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/WebSocketConnection.js
View
9 lib/WebSocketConnection.js
@@ -666,11 +666,18 @@ WebSocketConnection.prototype.sendFrame = function(frame, force, cb) {
};
WebSocketConnection.prototype.processOutgoingFrameQueue = function() {
- if (this.outputPaused || !this.connected) { return; }
+ if (this.outputPaused) { return; }
if (this.outgoingFrameQueue.length > 0) {
var current = this.outgoingFrameQueue.pop();
var buffer = current[0];
var cb = current[1];
+ // there is no need to accumulate messages in the queue if connection closed
+ // connection will not be restored and messages will never be sent
+ // therefore, notify callbacks about it
+ if (!this.connected && (typeof cb == 'function')) {
+ cb("Connection closed");
+ return;
+ }
try {
var flushed = this.socket.write(buffer, cb);
}
Please sign in to comment.
Something went wrong with that request. Please try again.