-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: Wrong value in bytesWritten for net.Socket #19562
Comments
I'm using a stream to send data like so:
The value of |
Unable to reproduce on mac with this code. Can you review and see where is the difference between our approaches? #cat 19562.js const n = require('net')
const v = n.createServer((s) => {
s.end(Buffer.alloc(process.argv[2] - 0).fill('g'), () => {
console.log(s.bytesWritten)
})
}).listen(8124, () => {
const c = n.connect(8124, () => {})
c.on('close', () => {v.close()})
}) #node 19562.js 1 #node -v
|
|
what is your
|
I don't seem to have that on my system (MacOS 10.13.3). |
I have added an
|
If it regressed between v9.6.1 and v9.7.0 then possibly the libuv update (1.19.2)? Maybe related to libuv/libuv#1739? |
thanks @patrickjuchli - following your hint I am able to reproduce in my system too, thought with different data volume, which does not matter. const n = require('net')
let count = 0
const v = n.createServer((s) => {
s.end(Buffer.alloc(process.argv[2] - 0).fill('g'), () => {
console.log(`server: bytes written: ${s.bytesWritten}`)
})
}).listen(8124, () => {
const c = n.connect(8124, () => {})
c.on('data', (d) => {count += d.length})
c.on('close', () => {
console.log(`client: data received: ${count}`)
v.close()
})
})
|
I tested with changes undone from libuv/libuv#1739 , but it did not solve this. |
confirmed. |
@gireeshpunathil thanks for investigating, and thanks for the ping! I think the issue is that The already-open #19551 should fix this particular issue with |
Thanks so much, @gireeshpunathil and @addaleax. |
I verified that #19551 indeed fixes this issue. |
Simply always tell the caller how many bytes were written, rather than letting them track it. In the case of writing a string, also keep track of the bytes written by the earlier `DoTryWrite()`. Refs: nodejs#19562
Fixes: nodejs#19562 PR-URL: nodejs#19551 Reviewed-By: James M Snell <jasnell@gmail.com>
Simply always tell the caller how many bytes were written, rather than letting them track it. In the case of writing a string, also keep track of the bytes written by the earlier `DoTryWrite()`. Refs: nodejs#19562 PR-URL: nodejs#19551 Reviewed-By: James M Snell <jasnell@gmail.com>
There is a regression since v9.7.0 (Darwin-x64) until and including v9.9.0:
If I send data with a net.Socket, the property
bytesWritten
won't reflect the correct number of byteswritten, it's always too low. I have verified this on the receiving end – data is written/sent as expected, only
bytesWritten
is incorrect.This works correctly until v9.6.1 (Darwin-x64).
The text was updated successfully, but these errors were encountered: