-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
events: add max listener warning for EventTarget #36001
Conversation
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.
Looks good - except the static on EventTarget.
Domenic pointed me towards https://heycam.github.io/webidl/#create-an-interface-object that does not allow adding additional properties.
This comment has been minimized.
This comment has been minimized.
34e87e4
to
53dc04d
Compare
This comment has been minimized.
This comment has been minimized.
@jasnell would it be possible to make it static on I think the DOM people and spec feel very strongly that once there are things added it's no longer a spec compliant EventTarget. |
Possible, yes, ideal, no? It would end up needing to be something like... events.setEventTargetMaxListeners(eventTarget, 5); Because the limit should be settable per |
Ok, this is the approach I just implemented: const events = require('events')
const et1 = new EventTarget();
const et2 = new EventTarget();
events.setEventTargetMaxListeners(15); // Set the default for all EventTargets
events.setEventTargetMaxListeners(15, et1); // Set the max for et1
events.setEventTargetMaxListeners(15, et1, et2); // Set the max for et1 and et2 It's not pretty but it works. |
53dc04d
to
abb7409
Compare
This comment has been minimized.
This comment has been minimized.
abb7409
to
1f87c08
Compare
I wouldn't see why not to be honest. They are functionally consistent with each other. |
--> | ||
|
||
* `n` {number} A non-negative number. The maximum number of listeners per | ||
`EventTarget` event. |
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.
`EventTarget` event. | |
`EventTarget` or `EventEmitter`. |
`EventTarget` event. | ||
* `...eventsTargets` {EventTarget[]|EventEmitter[]} Zero or more {EventTarget} | ||
or {EventEmitter} instances. If none are specified, `n` is set as the default | ||
max for all newly created {EventTarget} and {EventEmitter} objects. |
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.
max for all newly created {EventTarget} and {EventEmitter} objects. | |
maximum for all newly-created {EventTarget} and {EventEmitter} objects. |
Landed in cd31340...dc79f3f |
Signed-off-by: James M Snell <[email protected]> PR-URL: #36001 Fixes: #35990 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Signed-off-by: James M Snell <[email protected]> PR-URL: #36001 Fixes: #35990 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: TODO
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: TODO
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: #36232
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: #36232
Signed-off-by: James M Snell <[email protected]> PR-URL: nodejs#36001 Fixes: nodejs#35990 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Signed-off-by: James M Snell <[email protected]> PR-URL: nodejs#36001 Fixes: nodejs#35990 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Signed-off-by: James M Snell <[email protected]> PR-URL: nodejs#36001 Fixes: nodejs#35990 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Signed-off-by: James M Snell <[email protected]> PR-URL: #36001 Backport-PR-URL: #38386 Fixes: #35990 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Fixes: #35990
Signed-off-by: James M Snell [email protected]
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes