MCPcopy Index your code
hub / github.com/nodejs/node / socketOnDrain

Function socketOnDrain

lib/_http_server.js:867–889  ·  view source on GitHub ↗
(socket, state)

Source from the content-addressed store, hash-verified

865}
866
867function socketOnDrain(socket, state) {
868 const needPause = state.outgoingData > socket.writableHighWaterMark;
869
870 // If we previously paused, then start reading again.
871 if (socket._paused && !needPause) {
872 socket._paused = false;
873 if (socket.parser)
874 socket.parser.resume();
875 socket.resume();
876 }
877
878 const msg = socket._httpMessage;
879 // Only emit 'drain' once the message has no data pending anywhere, so that
880 // msg.writableLength === 0 when the event fires. socketOnDrain is called
881 // synchronously from updateOutgoingData during _flushOutput, at which point
882 // the bytes we just handed to the socket (or the stale outputSize) mean
883 // the message is not actually drained yet - we wait for the socket's
884 // own 'drain' event instead.
885 if (msg && !msg.finished && msg[kNeedDrain] && msg.writableLength === 0) {
886 msg[kNeedDrain] = false;
887 msg.emit('drain');
888 }
889}
890
891function socketOnTimeout() {
892 const req = this.parser?.incoming;

Callers 1

updateOutgoingDataFunction · 0.85

Calls 2

resumeMethod · 0.65
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…