From 9efa53222ba4a4898db26620ab5cecbcd7766607 Mon Sep 17 00:00:00 2001 From: emilfihlman Date: Thu, 9 Jun 2022 03:26:49 +0300 Subject: [PATCH] Fixed http_server timeout logic for requestTimeout and headerTimeout According to the documentation and also logic, headersTimeout should be smaller or equal to requestTimeout. This fixes the logic handling this check. Node could also clamp requestTimeout to headersTimeout if the latter is larger, but that's a design decision for a different person. I suspect there might be other range issues like this, too. --- lib/_http_server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index 48f825f15cb51d..c6a335185291a6 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -391,8 +391,8 @@ function storeHTTPOptions(options) { this.headersTimeout = 60_000; // 60 seconds } - if (this.requestTimeout > 0 && this.headersTimeout > 0 && this.headersTimeout >= this.requestTimeout) { - throw new codes.ERR_OUT_OF_RANGE('headersTimeout', '>= requestTimeout', headersTimeout); + if (this.requestTimeout > 0 && this.headersTimeout > 0 && this.headersTimeout > this.requestTimeout) { + throw new codes.ERR_OUT_OF_RANGE('headersTimeout', '<= requestTimeout', headersTimeout); } const keepAliveTimeout = options.keepAliveTimeout;