Skip to content

events: fix bug listenerCount don't compare wrapped listener - #48592

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
yuzheng14:fix/listenerCount-bug
Jul 10, 2023
Merged

events: fix bug listenerCount don't compare wrapped listener#48592
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
yuzheng14:fix/listenerCount-bug

Conversation

@yuzheng14

Copy link
Copy Markdown
Contributor

description

When add listener by once, it will be wrapped into another function. And when pass listener and there is just one event listener added by once, it will return 0 even if passed listener equal wrapped event listener.

This bug is included in #46523

Refs: #46523

how to trigger this

constee=newEventEmitter()constlistener=()=>undefinedee.once('event',listener)console.log('ee.listenerCount("event",listener)',ee.listenerCount('event',listener))

And it will output like this:

image

When add listener by once, it will be wrapped into another function.
And when pass listener and there is just one event listener added by
once, it will return 0 even if passed listener equal wrapped event
listener.
Refs: nodejs#46523
@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 Jun 29, 2023
@lpincalpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 29, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 29, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@yuzheng14

Copy link
Copy Markdown
ContributorAuthor

What do I need to do for this four failing checks?

image

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ShogunPanda

Copy link
Copy Markdown
Contributor

Nothing: those changes were unrelated to your PR. I resumed the build to let them succeed.

@yuzheng14

Copy link
Copy Markdown
ContributorAuthor

What do I need to do more for this pr? Or just waiting for merge?

@ShogunPandaShogunPanda added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jul 10, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 10, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 0c8539e into nodejs:mainJul 10, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0c8539e

juanarbol pushed a commit that referenced this pull request Jul 13, 2023
When add listener by once, it will be wrapped into another function.
And when pass listener and there is just one event listener added by
once, it will return 0 even if passed listener equal wrapped event
listener.
Refs: #46523
PR-URL: #48592
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
@juanarboljuanarbol mentioned this pull request Jul 13, 2023
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
When add listener by once, it will be wrapped into another function.
And when pass listener and there is just one event listener added by
once, it will return 0 even if passed listener equal wrapped event
listener.
Refs: nodejs#46523
PR-URL: nodejs#48592
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
When add listener by once, it will be wrapped into another function.
And when pass listener and there is just one event listener added by
once, it will return 0 even if passed listener equal wrapped event
listener.
Refs: nodejs#46523
PR-URL: nodejs#48592
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
ruyadorno pushed a commit that referenced this pull request Sep 11, 2023
When add listener by once, it will be wrapped into another function.
And when pass listener and there is just one event listener added by
once, it will return 0 even if passed listener equal wrapped event
listener.
Refs: #46523
PR-URL: #48592
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
@ruyadornoruyadorno mentioned this pull request Sep 11, 2023
ruyadorno pushed a commit that referenced this pull request Sep 13, 2023
When add listener by once, it will be wrapped into another function.
And when pass listener and there is just one event listener added by
once, it will return 0 even if passed listener equal wrapped event
listener.
Refs: #46523
PR-URL: #48592
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
ruyadorno pushed a commit that referenced this pull request Sep 17, 2023
When add listener by once, it will be wrapped into another function.
And when pass listener and there is just one event listener added by
once, it will return 0 even if passed listener equal wrapped event
listener.
Refs: #46523
PR-URL: #48592
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.eventsIssues and PRs related to the events subsystem / EventEmitter.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@yuzheng14@nodejs-github-bot@ShogunPanda@lpinca@JungMinu