Skip to content

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

@nicksia-vgwnicksia-vgw commented Aug 7, 2022

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

constserver=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){thrownewcodes.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.
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-botnodejs-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

@ShogunPandaShogunPanda 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.

LGTM!

@mcollinamcollina 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.

lgtm

@mcollinamcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2022
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2022
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added commit-queue Add this label to land a pull request using GitHub Actions. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed needs-ci PRs that need a full CI run. labels Aug 9, 2022
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 9, 2022
@nodejs-github-bot
nodejs-github-bot merged commit b427924 into nodejs:mainAug 9, 2022
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in b427924

@nicksia-vgw
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>
@ruyadornoruyadorno mentioned this pull request Aug 23, 2022
@juanarbol

Copy link
Copy Markdown
Member

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

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.httpIssues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@nicksia-vgw@nodejs-github-bot@juanarbol@mcollina@ShogunPanda@lpinca@tniessen@ErickWendel@rickyes