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

lib: http server, friendly error messages #22995

Closed
wants to merge 19 commits into from

Conversation

sagitsofan
Copy link
Contributor

@sagitsofan sagitsofan commented Sep 21, 2018

lib: improved error message description for the http server binding errors.

currently changed only in setupListenHandle function, but needs to be change all over.

Added new uvExceptionWithHostPort function (+export) in lib/internal/error.js that extracts the error message defined by libuv (using the error code) and returns an error object with the full error description.

example:
old error message: listen EADDRINUSE
new error message: listen EADDRINUSE: Address already in use

adjust tests to the new error.

Issue: #22936

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

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. net Issues and PRs related to the net subsystem. labels Sep 21, 2018
@sagitsofan sagitsofan changed the title Error msg 3 Https server :: Friendly error messages Sep 21, 2018
@sagitsofan sagitsofan changed the title Https server :: Friendly error messages http server : friendly error messages Sep 21, 2018
@sagitsofan sagitsofan changed the title http server : friendly error messages lib: http server, friendly error messages Sep 21, 2018
@joyeecheung joyeecheung added the semver-major PRs that contain breaking changes and should be released in the next major version. label Oct 5, 2018
@joyeecheung
Copy link
Member

cc @nodejs/tsc This is semver-major because it touches errors that are not in our ERR_CODE system and are potentially parsed by users.

@joyeecheung
Copy link
Member

@sagitsofan
Copy link
Contributor Author

sagitsofan commented Oct 5, 2018

It touches only in the error description and not in the error code which is stays the same, users are parsing the codes and not the error message.

@Trott
Copy link
Member

Trott commented Oct 5, 2018

/ping @nodejs/chakracore Is this compatible with ChakraCore or will this be something you'll need to patch over in node-chakracore if it lands in node?

@Trott
Copy link
Member

Trott commented Oct 5, 2018

users are parsing the codes and not the string.

Unfortunately, parsing of error message strings has been widespread in the ecosystem because there was no other alternative for a long time.

@addaleax
Copy link
Member

addaleax commented Oct 5, 2018

users are parsing the codes and not the string.

Unfortunately, parsing of error message strings has been widespread in the ecosystem because there was no other alternative for a long time.

As far as I can tell, these errors already do have a code property, so we shouldn’t have to consider thise semver-major.

@jasnell
Copy link
Member

jasnell commented Oct 5, 2018

If the errors already have a code, then changes do not have to be semver-major

@addaleax
Copy link
Member

addaleax commented Oct 5, 2018

@sagitsofan
Copy link
Contributor Author

sagitsofan commented Oct 5, 2018

Indeed errors have a code property, so users needs to parsed only the code and not the error message.
This PR changed only the description message that is returning to user.

Current error properties:

  code
  errno
  syscall
  address
  port

@Trott
Copy link
Member

Trott commented Oct 5, 2018

As far as I can tell, these errors already do have a code property, so we shouldn’t have to consider thise semver-major.

@addaleax Ah. I didn't see the usual tell-tale [ERR_CODE_THING] in the message string, but yes, indeed, there is a code property.

@joyeecheung
Copy link
Member

As far as I can tell, these errors already do have a code property, so we shouldn’t have to consider thise semver-major

Yes, but these are libuv error codes, not our supposed-to-be-permanent error codes, so less justification to not go semver-major. That said we can try a CITGM and see, worse case secnario this does break and we can always revert.

@addaleax
Copy link
Member

addaleax commented Oct 5, 2018

Yes, but these are libuv error codes, not our supposed-to-be-permanent error codes, so less justification to not go semver-major.

For the most part, libuv forwards errors returned from the OS, which are typically spec’d and therefore usually provide more long-term stability than our errors. Plus, changing an error code in libuv would definitely be semver-major on their side, so it would also land in a semver-major change in Node.js.

That said we can try a CITGM and see, worse case secnario this does break and we can always revert.

Yup – CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1570/

@addaleax addaleax removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Oct 5, 2018
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM as semver-major.

lib/internal/errors.js Outdated Show resolved Hide resolved
lib/internal/errors.js Outdated Show resolved Hide resolved
@sagitsofan sagitsofan force-pushed the error-msg-3 branch 2 times, most recently from e1d2978 to c3738fb Compare October 10, 2018 20:01
@addaleax
Copy link
Member

@sagitsofan I don’t know why, but for some reason, there’s over 50 commits listed in this PR – could you rebase this against master?

[Super-short how-to: git fetch [email protected]:nodejs/node.git +refs/heads/master && git rebase FETCH_HEAD, possibly followed by resolving conflicts + git rebase --continue (possibly repeated), then git push --force-with-lease]

Trott and others added 8 commits October 12, 2018 04:40
Use backticks around `SHASUM256.txt` etc. in README.md.

PR-URL: nodejs#23299
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Use fast-tracking on PRs where new Collaborators are adding themselves
to the README.

PR-URL: nodejs#23300
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
The internal `assert` modules `errorCache` property is exposed only for
testing. The one test that used it is rewritten here to not use it.

This has the following advantages:

* The test now makes sure that there is an empty cache in a more robust
  way. Instead of relying on the internal implementation of
  `errorCache`, it simply spawns a separate process.
* One less test using the `--expose-internals` flag.

PR-URL: nodejs#23304
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
The internal assert module exposed an errorCache property solely for
testing. It is no longer necessary. Remove it.

PR-URL: nodejs#23304
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Comments clarification at the deprecated function and new function.

Fixes: nodejs#22936
Comments clarification

Fixes: nodejs#22936
@sagitsofan
Copy link
Contributor Author

sagitsofan commented Oct 12, 2018

@addaleax Done, can it land?

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 12, 2018
@addaleax
Copy link
Member

CI: https://ci.nodejs.org/job/node-test-pull-request/17746/

@sagitsofan Thanks! There should be nothing you need to do here. :) I’ve added the author ready label, which means we’ll land this as soon as we can. If that doesn’t happen (and CI is good), feel free to ping us about that.

@addaleax
Copy link
Member

Landed in 82ea705 🎉 Thanks for the PR!

@addaleax addaleax closed this Oct 12, 2018
addaleax pushed a commit that referenced this pull request Oct 12, 2018
Improved error message description for the http server binding errors.

Currently changed only in `setupListenHandle`, but needs to be
change all over.

Added new `uvExceptionWithHostPort` function (+export) in
`lib/internal/error.js` that extracts the error message defined by
libuv, using the error code, and returns an error object with the
full error description.

example:
old error message: `listen EADDRINUSE`
new error message: `listen EADDRINUSE: Address already in use`

Removed exportable function `_exceptionWithHostPort` from
`lib/util.js` - exported by accident

Replaced `exceptionWithHostPort` to the new function
`uvExceptionWithHostPort` for a more detailed error.

Fixes: #22936

PR-URL: #22995
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@ericandrewlewis
Copy link

🎊 this will come out in version 12, right? Since the semver-major cut-off date for version 11 was October 2nd.

Trott pushed a commit that referenced this pull request Oct 13, 2018
Improved error message description for the http server binding errors.

Currently changed only in `setupListenHandle`, but needs to be
change all over.

Added new `uvExceptionWithHostPort` function (+export) in
`lib/internal/error.js` that extracts the error message defined by
libuv, using the error code, and returns an error object with the
full error description.

example:
old error message: `listen EADDRINUSE`
new error message: `listen EADDRINUSE: Address already in use`

Removed exportable function `_exceptionWithHostPort` from
`lib/util.js` - exported by accident

Replaced `exceptionWithHostPort` to the new function
`uvExceptionWithHostPort` for a more detailed error.

Fixes: #22936

PR-URL: #22995
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Oct 13, 2018
Improved error message description for the http server binding errors.

Currently changed only in `setupListenHandle`, but needs to be
change all over.

Added new `uvExceptionWithHostPort` function (+export) in
`lib/internal/error.js` that extracts the error message defined by
libuv, using the error code, and returns an error object with the
full error description.

example:
old error message: `listen EADDRINUSE`
new error message: `listen EADDRINUSE: Address already in use`

Removed exportable function `_exceptionWithHostPort` from
`lib/util.js` - exported by accident

Replaced `exceptionWithHostPort` to the new function
`uvExceptionWithHostPort` for a more detailed error.

Fixes: #22936

PR-URL: #22995
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@sagitsofan sagitsofan deleted the error-msg-3 branch October 13, 2018 15:55
@sagitsofan
Copy link
Contributor Author

sagitsofan commented Oct 13, 2018

@ericandrewlewis Version 10 is at October not version 11,
see https://github.com/nodejs/Release#release-schedule

jasnell pushed a commit that referenced this pull request Oct 17, 2018
Improved error message description for the http server binding errors.

Currently changed only in `setupListenHandle`, but needs to be
change all over.

Added new `uvExceptionWithHostPort` function (+export) in
`lib/internal/error.js` that extracts the error message defined by
libuv, using the error code, and returns an error object with the
full error description.

example:
old error message: `listen EADDRINUSE`
new error message: `listen EADDRINUSE: Address already in use`

Removed exportable function `_exceptionWithHostPort` from
`lib/util.js` - exported by accident

Replaced `exceptionWithHostPort` to the new function
`uvExceptionWithHostPort` for a more detailed error.

Fixes: #22936

PR-URL: #22995
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 30, 2018
Improved error message description for the http server binding errors.

Currently changed only in `setupListenHandle`, but needs to be
change all over.

Added new `uvExceptionWithHostPort` function (+export) in
`lib/internal/error.js` that extracts the error message defined by
libuv, using the error code, and returns an error object with the
full error description.

example:
old error message: `listen EADDRINUSE`
new error message: `listen EADDRINUSE: Address already in use`

Removed exportable function `_exceptionWithHostPort` from
`lib/util.js` - exported by accident

Replaced `exceptionWithHostPort` to the new function
`uvExceptionWithHostPort` for a more detailed error.

Fixes: #22936

PR-URL: #22995
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@codebytere codebytere mentioned this pull request Nov 27, 2018
rvagg pushed a commit that referenced this pull request Nov 28, 2018
Improved error message description for the http server binding errors.

Currently changed only in `setupListenHandle`, but needs to be
change all over.

Added new `uvExceptionWithHostPort` function (+export) in
`lib/internal/error.js` that extracts the error message defined by
libuv, using the error code, and returns an error object with the
full error description.

example:
old error message: `listen EADDRINUSE`
new error message: `listen EADDRINUSE: Address already in use`

Removed exportable function `_exceptionWithHostPort` from
`lib/util.js` - exported by accident

Replaced `exceptionWithHostPort` to the new function
`uvExceptionWithHostPort` for a more detailed error.

Fixes: #22936

PR-URL: #22995
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
Improved error message description for the http server binding errors.

Currently changed only in `setupListenHandle`, but needs to be
change all over.

Added new `uvExceptionWithHostPort` function (+export) in
`lib/internal/error.js` that extracts the error message defined by
libuv, using the error code, and returns an error object with the
full error description.

example:
old error message: `listen EADDRINUSE`
new error message: `listen EADDRINUSE: Address already in use`

Removed exportable function `_exceptionWithHostPort` from
`lib/util.js` - exported by accident

Replaced `exceptionWithHostPort` to the new function
`uvExceptionWithHostPort` for a more detailed error.

Fixes: #22936

PR-URL: #22995
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@codebytere codebytere mentioned this pull request Nov 29, 2018
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. errors Issues and PRs related to JavaScript errors originated in Node.js core. net Issues and PRs related to the net subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants