mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
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:
parent
8f4b4f272e
commit
312a4f3255
@ -541,7 +541,7 @@ ObjectDefineProperty(Socket.prototype, 'readyState', {
|
||||
ObjectDefineProperty(Socket.prototype, 'bufferSize', {
|
||||
get: function() {
|
||||
if (this._handle) {
|
||||
return this[kLastWriteQueueSize] + this.writableLength;
|
||||
return this.writableLength;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
client.on('end', common.mustCall());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user