File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 55 ArrayIsArray,
66 MathMin,
77 Number,
8+ NumberIsFinite,
89 ObjectAssign,
910 ObjectDefineProperty,
1011 ObjectEntries,
@@ -3389,6 +3390,20 @@ class Http2SecureServer extends TLSServer {
33893390 this . headersTimeout = 60_000 ; // Minimum between 60 seconds or requestTimeout
33903391 this . requestTimeout = 300_000 ; // 5 minutes
33913392 this . connectionsCheckingInterval = 30_000 ; // 30 seconds
3393+ const keepAliveTimeout = options . keepAliveTimeout ;
3394+ if ( keepAliveTimeout !== undefined ) {
3395+ validateInteger ( keepAliveTimeout , 'keepAliveTimeout' , 0 ) ;
3396+ this . keepAliveTimeout = keepAliveTimeout ;
3397+ } else {
3398+ this . keepAliveTimeout = 5_000 ; // 5 seconds;
3399+ }
3400+ const keepAliveTimeoutBuffer = options . keepAliveTimeoutBuffer ;
3401+ // Optional buffer added to the keep-alive timeout when setting socket timeouts.
3402+ // Helps reduce ECONNRESET errors from clients by extending the internal timeout.
3403+ // Default is 1000ms if not specified.
3404+ const buf = keepAliveTimeoutBuffer ;
3405+ this . keepAliveTimeoutBuffer =
3406+ ( typeof buf === 'number' && NumberIsFinite ( buf ) && buf >= 0 ) ? buf : 1000 ;
33923407 this . shouldUpgradeCallback = function ( ) {
33933408 return this . listenerCount ( 'upgrade' ) > 0 ;
33943409 } ;
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ const ca = fixtures.readKey('fake-startcom-root-cert.pem');
2020function onRequest ( request , response ) {
2121 const { socket : { alpnProtocol } } = request . httpVersion === '2.0' ?
2222 request . stream . session : request ;
23+ // Verify that keepAliveTimeout is set when allowHTTP1 is true
24+ assert . strictEqual ( typeof request . socket . server . keepAliveTimeout , 'number' ) ;
25+ assert . strictEqual ( request . socket . server . keepAliveTimeout , 5000 ) ;
2326 response . status ( 200 ) ;
2427 response . end ( JSON . stringify ( {
2528 alpnProtocol,
You can’t perform that action at this time.
0 commit comments