Repository navigation
lib: lazily initialize kEvents and kHandlers maps - #63702
Merged
Merged
Conversation
Collaborator
|
Review requested:
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR lazily initializes EventTarget’s internal listener/handler maps to reduce upfront allocation costs, and adds a benchmark to measure AbortController/AbortSignal creation overhead.
Changes:
- Lazily initialize
kEvents/kHandlers(undefineduntil first use) and add early returns/optional chaining in common EventTarget paths. - Update
lib/events.jshelpers to tolerate lazily-initialized EventTargets. - Add a benchmark covering
AbortController().signalandAbortSignal.timeout()creation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/internal/event_target.js | Switch internal maps to lazy init; adjust EventTarget/NodeEventTarget methods to handle undefined maps. |
| lib/events.js | Make getEventListeners() / listenerCount() resilient to missing kEvents map via optional chaining. |
| benchmark/abort_controller/abort-controller-creation.js | Add benchmark for AbortController signal creation and AbortSignal timeout creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
araujogui
force-pushed
the
event-target-lazy-init
branch
from
June 1, 2026 20:40
e810426 to
0b5feb1
Compare
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
araujogui
force-pushed
the
event-target-lazy-init
branch
from
June 1, 2026 20:47
0b5feb1 to
49fa612
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63702 +/- ##
==========================================
+ Coverage 90.30% 90.34% +0.04%
==========================================
Files 730 732 +2
Lines 235565 236713 +1148
Branches 44421 44604 +183
==========================================
+ Hits 212718 213859 +1141
+ Misses 14646 14555 -91
- Partials 8201 8299 +98
🚀 New features to boost your workflow:
|
Qard
approved these changes
Jun 2, 2026
gurgunday
approved these changes
Jun 2, 2026
Collaborator
Collaborator
Collaborator
|
Landed in 7e31299 |
richardlau
pushed a commit
that referenced
this pull request
Jul 3, 2026
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com> PR-URL: #63702 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
aduh95
pushed a commit
that referenced
this pull request
Jul 8, 2026
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com> PR-URL: #63702 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Jul 9, 2026
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [node](https://nodejs.org) ([source](https://github.com/nodejs/node)) | minor | `26.3.1` → `26.5.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>nodejs/node (node)</summary> ### [`v26.5.0`](https://github.com/nodejs/node/releases/tag/v26.5.0): 2026-07-08, Version 26.5.0 (Current), @​richardlau [Compare Source](nodejs/node@v26.3.1...v26.5.0) ##### Notable Changes ##### New release key Welcome to our newest releaser, [Stewart X Addison](https://github.com/sxa). Future Node.js releases may be signed with his [release key](https://github.com/nodejs/node/blob/main/README.md#release-keys), `655F3B5C1FB3FA8D1A0CA6BDE4A7D232B936D2FD`. ##### Other notable changes - \[[`55f48446c7`](nodejs/node@55f48446c7)] - **(SEMVER-MINOR)** **buffer**: implement blob.textStream() (Matthew Aitken) [#​64036](nodejs/node#64036) - \[[`b373202efc`](nodejs/node@b373202efc)] - **(SEMVER-MINOR)** **esm**: add `--experimental-import-text` flag (Efe) [#​62300](nodejs/node#62300) - \[[`39e0c14455`](nodejs/node@39e0c14455)] - **(SEMVER-MINOR)** **perf\_hooks**: sample delay per event loop iteration (Pablo Erhard) [#​62935](nodejs/node#62935) - \[[`999a83c937`](nodejs/node@999a83c937)] - **(SEMVER-MINOR)** **stream**: expose ReadableStreamTee (Matteo Collina) [#​64195](nodejs/node#64195) - \[[`4e0236dc3d`](nodejs/node@4e0236dc3d)] - **(SEMVER-MINOR)** **tls**: report negotiated TLS groups (Filip Skokan) [#​64119](nodejs/node#64119) ##### Commits - \[[`87648c0a6c`](nodejs/node@87648c0a6c)] - **benchmark**: trim down the argon2 sets (Filip Skokan) [#​64218](nodejs/node#64218) - \[[`a483bfd3f0`](nodejs/node@a483bfd3f0)] - **buffer**: remove unreachable overflow check in atob (haramjeong) [#​60161](nodejs/node#60161) - \[[`6d14279688`](nodejs/node@6d14279688)] - **buffer**: add fast api for isUtf8 and isAscii (Gürgün Dayıoğlu) [#​64169](nodejs/node#64169) - \[[`55f48446c7`](nodejs/node@55f48446c7)] - **(SEMVER-MINOR)** **buffer**: implement blob.textStream() (Matthew Aitken) [#​64036](nodejs/node#64036) - \[[`a67d9a7a44`](nodejs/node@a67d9a7a44)] - **build**: allow linting node.1 (Aviv Keller) [#​64157](nodejs/node#64157) - \[[`06c1fbc25b`](nodejs/node@06c1fbc25b)] - **build**: enable Maglev for riscv64 (Jamie Magee) [#​62605](nodejs/node#62605) - \[[`518309c363`](nodejs/node@518309c363)] - **build**: suppress clang errors building libffi on Windows (René) [#​64222](nodejs/node#64222) - \[[`6a80ab485c`](nodejs/node@6a80ab485c)] - **build**: add manually-dispatched stress-test workflow (Joyee Cheung) [#​64118](nodejs/node#64118) - \[[`f4e7bf1f1c`](nodejs/node@f4e7bf1f1c)] - **build**: pin envinfo versions in github actions (Joyee Cheung) [#​64117](nodejs/node#64117) - \[[`66f6ac0d86`](nodejs/node@66f6ac0d86)] - **build**: support setting an emulator from configure script (Ivan Trubach) [#​53899](nodejs/node#53899) - \[[`7f26c54aa6`](nodejs/node@7f26c54aa6)] - **child\_process**: fix permission model propagation via NODE\_OPTIONS (Matteo Collina) [#​63972](nodejs/node#63972) - \[[`32bb554f5b`](nodejs/node@32bb554f5b)] - **crypto**: fix large DH generator validation (Tobias Nießen) [#​64092](nodejs/node#64092) - \[[`0908d76ef6`](nodejs/node@0908d76ef6)] - **crypto**: reject small-order EdDSA points during verify (Filip Skokan) [#​64026](nodejs/node#64026) - \[[`7f7e5863c2`](nodejs/node@7f7e5863c2)] - **deps**: update undici to 8.7.0 (Node.js GitHub Bot) [#​64282](nodejs/node#64282) - \[[`af91029801`](nodejs/node@af91029801)] - **deps**: update nghttp3 to 1.17.0 (Node.js GitHub Bot) [#​64182](nodejs/node#64182) - \[[`2e500ba7b0`](nodejs/node@2e500ba7b0)] - **deps**: update googletest to [`8b53336`](nodejs/node@8b53336) (Node.js GitHub Bot) [#​64181](nodejs/node#64181) - \[[`74e3aa24ba`](nodejs/node@74e3aa24ba)] - **deps**: update sqlite to 3.53.3 (Node.js GitHub Bot) [#​64180](nodejs/node#64180) - \[[`c7e57f55a7`](nodejs/node@c7e57f55a7)] - **deps**: c-ares: cherry-pick [`8ba37af`](nodejs/node@8ba37af8e3fb) (René) [#​64110](nodejs/node#64110) - \[[`879fdc4daf`](nodejs/node@879fdc4daf)] - **deps**: V8: backport [`da20a19`](nodejs/node@da20a197a7f9) (Kevin Gibbons) [#​64101](nodejs/node#64101) - \[[`a640543a7c`](nodejs/node@a640543a7c)] - **deps**: V8: cherry-pick [`0cc9eb2`](nodejs/node@0cc9eb22c0b0) (Kevin Gibbons) [#​64101](nodejs/node#64101) - \[[`feefd179e5`](nodejs/node@feefd179e5)] - **deps**: V8: cherry-pick [`1a391f9`](nodejs/node@1a391f98cc7a) (Kevin Gibbons) [#​64101](nodejs/node#64101) - \[[`8ef643d4b0`](nodejs/node@8ef643d4b0)] - **deps**: update googletest to [`0b1e895`](nodejs/node@0b1e895) (Node.js GitHub Bot) [#​64039](nodejs/node#64039) - \[[`9e50bb0655`](nodejs/node@9e50bb0655)] - **dgram**: skip dns.lookup() for literal IP addresses (Ruben Bridgewater) [#​64133](nodejs/node#64133) - \[[`dc052c095c`](nodejs/node@dc052c095c)] - **diagnostics\_channel**: return original thenable (Stephen Belanger) [#​62407](nodejs/node#62407) - \[[`a22a840293`](nodejs/node@a22a840293)] - **doc**: clarify QUIC stream state wording (EduardF1) [#​63660](nodejs/node#63660) - \[[`8d4bec2d71`](nodejs/node@8d4bec2d71)] - **doc**: update Http2SecureServer.on("timeout") default value (YuSheng Chen) [#​64187](nodejs/node#64187) - \[[`da88f70afa`](nodejs/node@da88f70afa)] - **doc**: add note on visibility of CI failures to new contributor guide (Stewart X Addison) [#​64256](nodejs/node#64256) - \[[`20ce359ccb`](nodejs/node@20ce359ccb)] - **doc**: clarify HTTP/1.1 response ordering (Matteo Collina) [#​64213](nodejs/node#64213) - \[[`05eae2835c`](nodejs/node@05eae2835c)] - **doc**: recommend node-stress-single-test for flaky tests (Trivikram Kamat) [#​64223](
Defer allocation of
kEventsandkHandlersuntil first use instead of creating them unconditionally ininitEventTarget. This avoids twoMapallocations for everyEventTarget-derived object that never receives a listener, which is the common case forAbortSignal.Benchmarks