net: fix bufferSize

bufferSize should only look at writableLength otherwise it will
always show more than what is actually pending.

PR-URL: https://github.com/nodejs/node/pull/34088
Refs: https://github.com/nodejs/node/issues/34078
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Robert Nagy authored and Myles Borins committed 2020-07-16 17:08:56 -04:00
1 parent 41c80f6abe
commit b7e9b43b2f
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -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;
}
}
});
+1 -1
View File
@@ -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(() => {
@@ -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