Skip to content

Commit

Permalink
net: fix bufferSize
Browse files Browse the repository at this point in the history
bufferSize should only look at writableLength otherwise it will
always show more than what is actually pending.

PR-URL: #34088
Refs: #34078
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
ronag authored and MylesBorins committed Jul 14, 2020
1 parent 2ad3ec3 commit 0ddf376
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ ObjectDefineProperty(Socket.prototype, 'readyState', {
ObjectDefineProperty(Socket.prototype, 'bufferSize', {
get: function() {
if (this._handle) {
return this[kLastWriteQueueSize] + this.writableLength;
return this.writableLength;
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-buffersize.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ server.listen(0, common.mustCall(() => {

for (let i = 1; i < iter; i++) {
client.write('a');
assert.strictEqual(client.bufferSize, i + 1);
assert.strictEqual(client.bufferSize, i);
}

client.on('finish', common.mustCall(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-streamwrap-buffersize.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const net = require('net');

for (let i = 1; i < iter; i++) {
client.write('a');
assert.strictEqual(client.bufferSize, i + 1);
assert.strictEqual(client.bufferSize, i);
}

// It seems that tlsSockets created from sockets of `Duplex` emit no
Expand Down

0 comments on commit 0ddf376

Please sign in to comment.