Commit Graph

4 Commits

Author SHA1 Message Date
Neal Beeken
40ef2da8d6
events: remove abort listener from signal in on
the `abortHandler` function is declared within the scope of
the `events.on` function so cannot be removed by the caller
which can lead to a memory leak
adding the abort listener using the `addAbortListener` helper
returns a disposable that can be used to clean up the listener
when the iterator is exited

Fixes: https://github.com/nodejs/node/issues/51010
PR-URL: https://github.com/nodejs/node/pull/51091
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2024-03-15 15:10:59 +00:00
Deokjin Kim
7ace5aba75
events: validate options of on and once
Check whether options is object or not to avoid passing
invalid type as options to `on` and `once`.

Refs: https://nodejs.org/dist/latest-v19.x/docs/api/events.html#eventsonceemitter-name-options
PR-URL: https://github.com/nodejs/node/pull/46018
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2023-09-29 10:56:20 +00:00
Rich Trott
d5d7a416c7
test: add trailing commas in event tests
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: https://github.com/nodejs/node/pull/45448#pullrequestreview-1179370442
PR-URL: https://github.com/nodejs/node/pull/45466
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-11-22 23:03:33 +00:00
Rongjian Zhang
a596fdf4d6 test: improve coverage of lib/events.js
PR-URL: https://github.com/nodejs/node/pull/38582
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2021-06-11 02:35:14 +00:00