FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

http: fix error message when specifying headerTimeout for createServer by nicksia-vgw · Pull Request #44163 · nodejs/node · GitHub

/ node Public

http: fix error message when specifying headerTimeout for createServer - #44163

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
nicksia-vgw:fix-incorrect-headertimeout-error-message
Aug 9, 2022
Merged

http: fix error message when specifying headerTimeout for createServer#44163
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
nicksia-vgw:fix-incorrect-headertimeout-error-message

Conversation

nicksia-vgw commented Aug 7, 2022
edited by VoltrexKeyva
Loading

Copy link
Copy Markdown
Contributor

This change fixes a misleading error message provided by the error thrown when creating an http server with a headerTimeout that exceeds the requestTimeout.

Code

const server = createServer({
  headersTimeout: 6000, // Limit the amount of time the parser will wait to receive the complete HTTP headers.
  requestTimeout: 3000, // Sets the timeout value in milliseconds for receiving the entire request from the client.
}, () => {});

Error

node:_http_server:406
    throw new codes.ERR_OUT_OF_RANGE('headersTimeout', '>= requestTimeout', headersTimeout);
    ^

RangeError [ERR_OUT_OF_RANGE]: The value of "headersTimeout" is out of range. It must be >= requestTimeout. Received 6000

The header timeout is actually required to be < the request timeout (which is correctly validated), but the error message is wrong - see original snippet below.

_http_server.js.storeHTTPOptions (validation code)

  if (this.requestTimeout > 0 && this.headersTimeout > 0 && this.headersTimeout >= this.requestTimeout) {
    throw new codes.ERR_OUT_OF_RANGE('headersTimeout', '>= requestTimeout', headersTimeout);
  }

This change fixes the message on the error received when calling 
http.createServer(...) with a header timeout greater than the request
timeout is incorrect.

The validation requires that the header timeout is lower than the 
request timeout, but the error message asks for the opposite.

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

nodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Aug 7, 2022

ShogunPanda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2022

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

mcollina added commit-queue Add this label to land a pull request using GitHub Actions. author ready PRs that have at least one approval, no outstanding review comments, and a CI started. and removed needs-ci PRs that need a full CI run. labels Aug 9, 2022
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 9, 2022
nodejs-github-bot merged commit b427924 into nodejs:main Aug 9, 2022

Copy link
Copy Markdown
Collaborator

Landed in b427924

nicksia-vgw deleted the fix-incorrect-headertimeout-error-message branch August 9, 2022 09:33
danielleadams pushed a commit that referenced this pull request Aug 16, 2022
This change fixes the message on the error received when calling
http.createServer(...) with a header timeout greater than the request
timeout is incorrect.

The validation requires that the header timeout is lower than the
request timeout, but the error message asks for the opposite.

PR-URL: #44163
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
ruyadorno pushed a commit that referenced this pull request Aug 23, 2022
This change fixes the message on the error received when calling
http.createServer(...) with a header timeout greater than the request
timeout is incorrect.

The validation requires that the header timeout is lower than the
request timeout, but the error message asks for the opposite.

PR-URL: #44163
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>

Copy link
Copy Markdown
Member

This change depends on #41263 which is a semver-major PR

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. http Issues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL