-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
[v12.x] events: assume an EventEmitter if emitter.on is a function #35818
Conversation
Assume that the `emitter` argument of `EventEmitter.once()` is an `EventEmitter` if `emitter.on` is a function. Refs: nodejs@4b3654e923e7c3c2 Refs: websockets/ws#1795
This fixes a breaking change introduced in 9150c4dc72. The |
@lpinca note that that PR was added in order to support |
I don't think this use case (of something that behaves like both eventemitter and eventtarget) is common and a quick GitHub search doesn't find interesting results. I am fine with landing this change as semver-patch. Preferring The biggest difference here is error handling (adding the |
Also fwiw I am fine with this change in master (and not just 12.x) |
On master, v15.x, and v14.x it's already like this. See linked refs. |
@lpinca Ah lmao, I am the author of that and absolutely forgot about that 😅 |
This comment has been minimized.
This comment has been minimized.
@nodejs/events can we please get one more sign off on this |
pinging @nodejs/events can we please get another sign-off here? maybe @mcollina ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Landed in a211c70e04aa |
Assume that the `emitter` argument of `EventEmitter.once()` is an `EventEmitter` if `emitter.on` is a function. Refs: 4b3654e923e7c3c2 Refs: websockets/ws#1795 PR-URL: #35818 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Assume that the
emitter
argument ofEventEmitter.once()
is anEventEmitter
ifemitter.on
is a function.Refs: 4b3654e923e7c3c2
Refs: websockets/ws#1795
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes