Skip to content

Commit cd2ff46

Browse files
[fix] Only add defined callbacks to the stack (#447)
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
1 parent c650358 commit cd2ff46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/socket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ Socket.prototype.sendPacket = function (type, data, options, callback) {
393393

394394
this.writeBuffer.push(packet);
395395

396-
// add send callback to object
397-
this.packetsFn.push(callback);
396+
// add send callback to object, if defined
397+
if (callback) this.packetsFn.push(callback);
398398

399399
this.flush();
400400
}

0 commit comments

Comments
 (0)