Skip to content

fix(ext/node): attach addAbortListener to EventEmitter, fix errorMonitor - #34262

Merged
bartlomieju merged 1 commit into
mainfrom
fix/node-events-addabortlistener
May 20, 2026
Merged

bartlomieju merged 1 commit into
mainfrom
fix/node-events-addabortlistener

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

require("node:events").addAbortListener was undefined, so libraries
that hit the CJS path (notably undici 8.x used by npm:undici) crashed
with addAbortListenerNative is not a function. Node attaches every
named export as a static property on the EventEmitter constructor, and
that's also what the ESM default export points at; Deno did this for
most properties but had never assigned EventEmitter.addAbortListener,
so both the CJS export and import events from "node:events" were
missing it.

The same file also captured the local errorMonitor binding before
EventEmitter.errorMonitor = kErrorMonitor ran, so the named export and
the namespace import resolved to undefined even though the property
on the constructor itself was correct. Both bindings now read from
kErrorMonitor directly.

Fixes #34261

@bartlomieju
bartlomieju merged commit 0213399 into main May 20, 2026
268 of 270 checks passed
@bartlomieju
bartlomieju deleted the fix/node-events-addabortlistener branch May 20, 2026 09:56
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…tor (denoland#34262)

`require("node:events").addAbortListener` was `undefined`, so libraries
that hit the CJS path (notably undici 8.x used by `npm:undici`) crashed
with `addAbortListenerNative is not a function`. Node attaches every
named export as a static property on the `EventEmitter` constructor, and
that's also what the ESM default export points at; Deno did this for
most properties but had never assigned `EventEmitter.addAbortListener`,
so both the CJS export and `import events from "node:events"` were
missing it.

The same file also captured the local `errorMonitor` binding before
`EventEmitter.errorMonitor = kErrorMonitor` ran, so the named export and
the namespace import resolved to `undefined` even though the property
on the constructor itself was correct. Both bindings now read from
`kErrorMonitor` directly.

Fixes denoland#34261
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ext/node: implement node:events addAbortListener

1 participant