Skip to content

Commit

Permalink
[fix] Only add defined callbacks to the stack (#447)
Browse files Browse the repository at this point in the history
Before that commit, undefined callbacks were also added to the array,
which could lead to 'Maximum call stack size exceeded' error when
flush() method was called.

Fixes #399
  • Loading branch information
darrachequesne authored Nov 21, 2016
1 parent c650358 commit cd2ff46
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ Socket.prototype.sendPacket = function (type, data, options, callback) {

this.writeBuffer.push(packet);

// add send callback to object
this.packetsFn.push(callback);
// add send callback to object, if defined
if (callback) this.packetsFn.push(callback);

this.flush();
}
Expand Down

0 comments on commit cd2ff46

Please sign in to comment.