@@ -154,6 +154,7 @@ const {
154154 startPerf,
155155 stopPerf,
156156} = require ( 'internal/perf/observe' ) ;
157+ const { getDefaultHighWaterMark } = require ( 'internal/streams/state' ) ;
157158
158159function getFlags ( ipv6Only ) {
159160 return ipv6Only === true ? TCPConstants . UV_TCP_IPV6ONLY : 0 ;
@@ -1682,6 +1683,15 @@ function Server(options, connectionListener) {
16821683 options . keepAliveInitialDelay = 0 ;
16831684 }
16841685 }
1686+ if ( typeof options . highWaterMark !== 'undefined' ) {
1687+ validateNumber (
1688+ options . highWaterMark , 'options.highWaterMark' ,
1689+ ) ;
1690+
1691+ if ( options . highWaterMark < 0 ) {
1692+ options . highWaterMark = getDefaultHighWaterMark ( ) ;
1693+ }
1694+ }
16851695
16861696 this . _connections = 0 ;
16871697
@@ -1696,6 +1706,7 @@ function Server(options, connectionListener) {
16961706 this . noDelay = Boolean ( options . noDelay ) ;
16971707 this . keepAlive = Boolean ( options . keepAlive ) ;
16981708 this . keepAliveInitialDelay = ~ ~ ( options . keepAliveInitialDelay / 1000 ) ;
1709+ this . highWaterMark = options . highWaterMark ?? getDefaultHighWaterMark ( ) ;
16991710}
17001711ObjectSetPrototypeOf ( Server . prototype , EventEmitter . prototype ) ;
17011712ObjectSetPrototypeOf ( Server , EventEmitter ) ;
@@ -2077,6 +2088,8 @@ function onconnection(err, clientHandle) {
20772088 pauseOnCreate : self . pauseOnConnect ,
20782089 readable : true ,
20792090 writable : true ,
2091+ readableHighWaterMark : self . highWaterMark ,
2092+ writableHighWaterMark : self . highWaterMark ,
20802093 } ) ;
20812094
20822095 if ( self . noDelay && clientHandle . setNoDelay ) {
0 commit comments