Skip to content

Commit ce5d0db

Browse files
ronagaddaleax
authored andcommitted
net: fix bufferSize
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 <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 09a1289 commit ce5d0db

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/net.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ ObjectDefineProperty(Socket.prototype, 'readyState', {
552552
ObjectDefineProperty(Socket.prototype, 'bufferSize', {
553553
get: function() {
554554
if (this._handle) {
555-
return this[kLastWriteQueueSize] + this.writableLength;
555+
return this.writableLength;
556556
}
557557
}
558558
});

test/parallel/test-tls-buffersize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ server.listen(0, common.mustCall(() => {
3131

3232
for (let i = 1; i < iter; i++) {
3333
client.write('a');
34-
assert.strictEqual(client.bufferSize, i + 1);
34+
assert.strictEqual(client.bufferSize, i);
3535
}
3636

3737
client.on('finish', common.mustCall(() => {

test/parallel/test-tls-streamwrap-buffersize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const net = require('net');
5656

5757
for (let i = 1; i < iter; i++) {
5858
client.write('a');
59-
assert.strictEqual(client.bufferSize, i + 1);
59+
assert.strictEqual(client.bufferSize, i);
6060
}
6161

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

0 commit comments

Comments
 (0)