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: refactor to use validateCallback #36609

Closed
wants to merge 1 commit into from

Conversation

Lxxyx
Copy link
Member

@Lxxyx Lxxyx commented Dec 23, 2020

Try replacing all duplicate checks with validateCallback, Due to the scope of the changes, it may be necessary to run a benchmark.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Dec 23, 2020
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Definitely not for this PR, but for what it's worth, I'd be in favor getting rid of ERR_INVALID_CALLBACK entirely and using ERR_INVALID_ARG_TYPE instead. It is very difficult for me to imagine a situation where ERR_INVALID_CALLBACK is more useful to someone than ERR_INVALID_ARG_TYPE. On the other hand, it is easy for me to imagine a situation where someone has to check for both ERR_INVALID_ARG_TYPE and ERR_INVALID_CALLBACK but they don't know it and they're only checking for ERR_INVALID_ARG_TYPE. Node.js has too many error codes and they are often not specific in a way that is helpful to end users. ERR_INVALID_CALLBACK seems to be one of those cases.

@Trott Trott added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 23, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 23, 2020
@nodejs-github-bot
Copy link
Collaborator

@Lxxyx
Copy link
Member Author

Lxxyx commented Dec 23, 2020

Definitely not for this PR, but for what it's worth, I'd be in favor getting rid of ERR_INVALID_CALLBACK entirely and using ERR_INVALID_ARG_TYPE instead. It is very difficult for me to imagine a situation where ERR_INVALID_CALLBACK is more useful to someone than ERR_INVALID_ARG_TYPE. On the other hand, it is easy for me to imagine a situation where someone has to check for both ERR_INVALID_ARG_TYPE and ERR_INVALID_CALLBACK but they don't know it and they're only checking for ERR_INVALID_ARG_TYPE. Node.js has too many error codes and they are often not specific in a way that is helpful to end users. ERR_INVALID_CALLBACK seems to be one of those cases.

Thanks for the reply, very valuable thought. node.js does have too many error codes, I was confused when I first opened the error.js file too.

ERR_INVALID_CALLBACK and ERR_INVALID_ARG_TYPE are also duplicates, and I personally agree with using ERR_INVALID_ARG_TYPE for both.

However, ERR_INVALID_CALLBACK being a widely used error code, replacing it with ERR_INVALID_ARG_TYPE may cause compatibility issues. Perhaps we can replace it with ERR_INVALID_ARG_TYPE in the next major release?

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Dec 28, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 28, 2020
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 29, 2020
@github-actions github-actions bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 29, 2020
@github-actions
Copy link
Contributor

Landed in 8cf5ae0...b00bb01

@github-actions github-actions bot closed this Dec 29, 2020
nodejs-github-bot pushed a commit that referenced this pull request Dec 29, 2020
PR-URL: #36609
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 12, 2021
PR-URL: #36609
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@danielleadams danielleadams mentioned this pull request Jan 12, 2021
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. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants