Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/lib/net.js b/lib/net.js
index d0a2c5a..42c2109 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -595,9 +595,12 @@ Socket.prototype._write = function(dataEncoding, cb) {
return this._destroy(errnoException(errno, 'write'), cb);
writeReq.oncomplete = afterWrite;
- writeReq.cb = cb;
-
this._bytesDispatched += writeReq.bytes;
+
+ if (this._handle.writeQueueSize === 0)
+ cb();
+ else
+ writeReq.cb = cb;
};
@@ -640,7 +643,8 @@ function afterWrite(status, handle, req) {
if (self !== process.stderr && self !== process.stdout)
debug('afterWrite call cb');
- req.cb.call(self);
+ if (req.cb)
+ req.cb.call(self);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.