Skip to content

events: refactor to use validator - #45448

Closed
Lxxyx wants to merge 3 commits into
nodejs:mainfrom
Lxxyx:refactor/events-use-validator
Closed

events: refactor to use validator#45448
Lxxyx wants to merge 3 commits into
nodejs:mainfrom
Lxxyx:refactor/events-use-validator

Conversation

@Lxxyx

@LxxyxLxxyx commented Nov 13, 2022

Copy link
Copy Markdown
Member

Use validateNumber() for events(setMaxListeners/defaultMaxListeners).

If passed wrong parameter types, validateNumber() will throw ERR_INVALID_ARG_TYPE instead of original error code: ERR_OUT_OF_RANGE. I think ERR_INVALID_ARG_TYPE is more accurate.

@nodejs-github-botnodejs-github-bot added events Issues and PRs related to the events subsystem / EventEmitter. needs-ci PRs that need a full CI run. labels Nov 13, 2022
@TrottTrott added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 13, 2022
@Trott

Copy link
Copy Markdown
Member

At least in theory, something that changes an error code is semver major so I added that label. But if others feel strongly that it isn't, I'm ok with it being removed and treating this as a bug fix.

@anonrig

Copy link
Copy Markdown
Member

I agree with @Trott. There might be some packages that depend on this error message, and therefore I'm good with semver-major label.

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

Let's not validate the error messages.

Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Comment threadtest/parallel/test-event-emitter-max-listeners.js Outdated
Trott added a commit to Trott/io.js that referenced this pull request Nov 15, 2022
As much as I would like to do this everywhere and then modify the lint
rule to enforce it, the churn would be too big. However if we're going
to have relatively frequent nits for this sort of thing (as we do), I'd
prefer we migrate a few files at a time to never actually getting around
to doing it.
Ref: nodejs#45448 (review)

@jasnelljasnell 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 as a semver major. This should have a benchmark run before it lands.

nodejs-github-bot pushed a commit that referenced this pull request Nov 22, 2022
As much as I would like to do this everywhere and then modify the lint
rule to enforce it, the churn would be too big. However if we're going
to have relatively frequent nits for this sort of thing (as we do), I'd
prefer we migrate a few files at a time to never actually getting around
to doing it.
Ref: #45448 (review)
PR-URL: #45466
Reviewed-By: James M Snell <jasnell@gmail.com>
ruyadorno pushed a commit that referenced this pull request Nov 24, 2022
As much as I would like to do this everywhere and then modify the lint
rule to enforce it, the churn would be too big. However if we're going
to have relatively frequent nits for this sort of thing (as we do), I'd
prefer we migrate a few files at a time to never actually getting around
to doing it.
Ref: #45448 (review)
PR-URL: #45466
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
As much as I would like to do this everywhere and then modify the lint
rule to enforce it, the churn would be too big. However if we're going
to have relatively frequent nits for this sort of thing (as we do), I'd
prefer we migrate a few files at a time to never actually getting around
to doing it.
Ref: #45448 (review)
PR-URL: #45466
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
As much as I would like to do this everywhere and then modify the lint
rule to enforce it, the churn would be too big. However if we're going
to have relatively frequent nits for this sort of thing (as we do), I'd
prefer we migrate a few files at a time to never actually getting around
to doing it.
Ref: #45448 (review)
PR-URL: #45466
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 5, 2023
As much as I would like to do this everywhere and then modify the lint
rule to enforce it, the churn would be too big. However if we're going
to have relatively frequent nits for this sort of thing (as we do), I'd
prefer we migrate a few files at a time to never actually getting around
to doing it.
Ref: #45448 (review)
PR-URL: #45466
Reviewed-By: James M Snell <jasnell@gmail.com>
@aduh95

Copy link
Copy Markdown
Contributor

@Lxxyx this needs a rebase

@aduh95

Copy link
Copy Markdown
Contributor

This PR has conflicts that must be resolved

@Lxxyx

Copy link
Copy Markdown
MemberAuthor

Close due to #45770

@LxxyxLxxyx closed this Mar 10, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eventsIssues and PRs related to the events subsystem / EventEmitter.needs-ciPRs that need a full CI run.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@Lxxyx@Trott@anonrig@aduh95@jasnell@nodejs-github-bot