Skip to content

Implement node:events events.on async iterator parity #1183

@TheHypnoo

Description

@TheHypnoo

Summary

The granular node:events parity suite has one remaining known failure: module-level events.on(emitter, eventName) should return an async iterator that yields arrays of emitted event arguments.

Repro

import { EventEmitter, on } from "node:events";

const em = new EventEmitter();
const iter = on(em, "data");
em.emit("data", 1);
em.emit("data", 2);
em.emit("data", 3);
const seen: number[] = [];
for await (const args of iter) {
  seen.push(args[0]);
  if (seen.length === 3) break;
}
console.log("seen:", seen);

Node prints:

seen: [ 1, 2, 3 ]

Perry currently prints:

seen: []

Tracking test

test-parity/node-suite/events/on/async-iterator-basic.ts

Currently listed in test-parity/known_failures.json as node-suite/events/on/async-iterator-basic.

Notes

This likely needs a real async-iterator object backed by EventEmitter listener queues. It is larger than the small EventEmitter runtime fixes already added for once, meta-events, module properties, and addAbortListener.

Metadata

Metadata

Assignees

No one assigned

    Labels

    parityNode.js compatibility / parity gaps

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions