@@ -1025,11 +1025,16 @@ function resOnFinish(req, res, socket, state, server) {
|
1025 | 1025 | socket.end(); |
1026 | 1026 | } |
1027 | 1027 | } else if (state.outgoing.length === 0) { |
1028 | | -if (server.keepAliveTimeout && typeof socket.setTimeout === 'function') { |
| 1028 | +const keepAliveTimeout = NumberIsFinite(server.keepAliveTimeout) && server.keepAliveTimeout >= 0 ? |
| 1029 | +server.keepAliveTimeout : 0; |
| 1030 | +const keepAliveTimeoutBuffer = NumberIsFinite(server.keepAliveTimeoutBuffer) && server.keepAliveTimeoutBuffer >= 0 ? |
| 1031 | +server.keepAliveTimeoutBuffer : 1e3; |
| 1032 | + |
| 1033 | +if (keepAliveTimeout && typeof socket.setTimeout === 'function') { |
1029 | 1034 | // Extend the internal timeout by the configured buffer to reduce |
1030 | 1035 | // the likelihood of ECONNRESET errors. |
1031 | 1036 | // This allows fine-tuning beyond the advertised keepAliveTimeout. |
1032 | | -socket.setTimeout(server.keepAliveTimeout + server.keepAliveTimeoutBuffer); |
| 1037 | +socket.setTimeout(keepAliveTimeout + keepAliveTimeoutBuffer); |
1033 | 1038 | state.keepAliveTimeoutSet = true; |
1034 | 1039 | } |
1035 | 1040 | } else { |
|