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

http: improve parser error messages #28487

Closed
wants to merge 1 commit into from

Conversation

addaleax
Copy link
Member

Include the library-provided reason in the Error’s message.

Fixes: #28468

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Include the library-provided reason in the Error’s `message`.

Fixes: nodejs#28468
@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jun 30, 2019
@indutny
Copy link
Member

indutny commented Jun 30, 2019

Fantastic!

Copy link
Member

@indutny indutny left a comment

Choose a reason for hiding this comment

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

LGTM

@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 1, 2019
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@trivikr trivikr left a comment

Choose a reason for hiding this comment

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

LGTM, a minor nit

const req = http.get(`http://localhost:${server.address().port}/`);
req.end();
req.on('error', common.mustCall((err) => {
const reason = 'Content-Length can\'t be present with chunked encoding';
Copy link
Member

Choose a reason for hiding this comment

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

nit: backticks instead of single quotes to avoid escaping

Suggested change
const reason = 'Content-Length can\'t be present with chunked encoding';
const reason = `Content-Length can't be present with chunked encoding`;

Copy link
Member

Choose a reason for hiding this comment

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

As note: using backticks would not be accepted by eslint. Only double quotes would be accepted. Using backticks is only accepted by eslint if the template string contains a variable.

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Jul 6, 2019

Landed in ba565a3

Trott pushed a commit to Trott/io.js that referenced this pull request Jul 6, 2019
Include the library-provided reason in the Error’s `message`.

Fixes: nodejs#28468

PR-URL: nodejs#28487
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@Trott Trott closed this Jul 6, 2019
targos pushed a commit that referenced this pull request Jul 20, 2019
Include the library-provided reason in the Error’s `message`.

Fixes: #28468

PR-URL: #28487
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This was referenced Jul 23, 2019
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 pending requests for changes, 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.

Better communication / errors around node 12 breaking HTTP parser changes
9 participants