You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In nodejs 18.18.2 im trying to measure the activity of WritableStream by looking at the _writableState of the TLSSocket from server.on("upgrade", (req,socket,head)), where the websocketserver sender (https://github.com/websockets/ws/blob/master/lib/sender.js#L469) is writing to in order to find when it does actually push to the kernel buffers as docs suggests it may not be immediately. I could not find any easy way to debug or diagnose this, so I decided to log the writable state by increasing or decreasing the highWaterMark on the writable socket, to my surprise the _writableState does not change and always stays like this:
async function onNext(context, message, _args, result) {
console.log(currentSocket._writableState); //always the same?
}
Next to simulate reading chunks of 4MB and emitting into the AsyncIterator, also 1MB or 16MB and i was expecting to see at least once needDrain: true or lengh:0 to change in order to understand when it is in fact written to the kernel and how much does it write.
It appears that changing the default highwater mark does work on the same socket since i can see improvement in throughput only at 256k and 512k and lower network throughput otherwise but the writable state never changes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
In nodejs 18.18.2 im trying to measure the activity of WritableStream by looking at the _writableState of the TLSSocket from server.on("upgrade", (req,socket,head)), where the websocketserver sender (https://github.com/websockets/ws/blob/master/lib/sender.js#L469) is writing to in order to find when it does actually push to the kernel buffers as docs suggests it may not be immediately. I could not find any easy way to debug or diagnose this, so I decided to log the writable state by increasing or decreasing the highWaterMark on the writable socket, to my surprise the _writableState does not change and always stays like this:
on server:
Later writing using AsyncIterator onNext method and websocket is created from the latest WebSocket.Server.completeUpgrade:
next call chain for the socket write: https://github.com/websockets/ws/blob/master/lib/sender.js#L469
Adding onNext method above logs the _writetableState:
Next to simulate reading chunks of 4MB and emitting into the AsyncIterator, also 1MB or 16MB and i was expecting to see at least once needDrain: true or lengh:0 to change in order to understand when it is in fact written to the kernel and how much does it write.
It appears that changing the default highwater mark does work on the same socket since i can see improvement in throughput only at 256k and 512k and lower network throughput otherwise but the writable state never changes.
Is this intended or i'm doing something wrong?
Beta Was this translation helpful? Give feedback.
All reactions