Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: improve errors thrown in header validation #16718

Closed
wants to merge 1 commit into from

Conversation

joyeecheung
Copy link
Member

Previously #16715

This PR:

  • Include the header name and the value in ERR_HTTP2_INVALID_HEADER_VALUE for debug-ability as [REQUEST] Better Errors in http validate headers #16714 suggests. Before it's Value must not be undefined or null, after it's Invalid value "undefined" for header "test". If the user is setting the header in a loop this would be much more useful.
  • Use Error.captureStackTrace to exclude the validation functions from the stack trace
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

http2

@nodejs-github-bot nodejs-github-bot added dont-land-on-v4.x errors Issues and PRs related to JavaScript errors originated in Node.js core. http2 Issues or PRs related to the http2 subsystem. labels Nov 3, 2017
@joyeecheung
Copy link
Member Author

@@ -837,7 +837,7 @@ requests and responses.
<a id="ERR_HTTP2_INVALID_HEADER_VALUE"></a>
### ERR_HTTP2_INVALID_HEADER_VALUE

Used to indicate that an invalid HTTP/2 header value has been specified.
Used to indicate that an invalid HTTP2 header value has been specified.
Copy link
Member Author

Choose a reason for hiding this comment

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

Uh, accidental...can be fixed later.

err = new errors.TypeError('ERR_HTTP2_INVALID_HEADER_VALUE', value, name);
}
if (err !== undefined) {
Error.captureStackTrace(err, assertValidHeader);
Copy link
Member

@lpinca lpinca Nov 5, 2017

Choose a reason for hiding this comment

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

Is there a particular reason to remove assertValidHeader from the stack trace?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lpinca I don't think that frame adds more value to the stacktrace because you can easily tell which line it would be by the error thrown, and the error codes themselves are clear enough to show the reason. Adding one more frame just expose more internal details that the user should not worry about..

Copy link
Member

Choose a reason for hiding this comment

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

because you can easily tell which line it would be by the error thrown

Yes, but it should be inferred and it requires a little more effort. Internal details are useful for everyone when debugging. Anyway no problem, I can live with it :)

joyeecheung added a commit that referenced this pull request Nov 6, 2017
PR-URL: #16718
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@joyeecheung
Copy link
Member Author

Landed in 11a9f36, thanks!

@joyeecheung joyeecheung closed this Nov 6, 2017
cjihrig pushed a commit to cjihrig/node that referenced this pull request Nov 6, 2017
PR-URL: nodejs#16718
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@cjihrig cjihrig mentioned this pull request Nov 6, 2017
gibfahn pushed a commit that referenced this pull request Nov 14, 2017
PR-URL: #16718
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@gibfahn gibfahn mentioned this pull request Nov 21, 2017
gibfahn added a commit that referenced this pull request Dec 5, 2017
Notable Changes:

- **console**:
  - avoid adding infinite error listeners (Matteo Collina) [#16770](https://github.com/nodejs/n
de/pull/16770)
- **http2**:
  - improve errors thrown in header validation (Joyee Cheung) [#16718](https://github.com/nodej
s/node/pull/16718)

PR-URL: #17204
gibfahn added a commit that referenced this pull request Dec 5, 2017
Notable Changes:

- **console**:
  - avoid adding infinite error listeners (Matteo Collina) [#16770](https://github.com/nodejs/n
de/pull/16770)
- **http2**:
  - improve errors thrown in header validation (Joyee Cheung) [#16718](https://github.com/nodej
s/node/pull/16718)

PR-URL: #17204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants