Skip to content

events.once creates an error listener that is not removed on abort. #36949

@draivin

Description

@draivin
  • Version: v15.5.0
  • Platform: Microsoft Windows NT 10.0.20279.0 x64
  • Subsystem:

What steps will reproduce the bug?

let events = require('events');

let ac = new AbortController();
let e = new events.EventEmitter();

events.once(e, 'test', {signal: ac.signal});

ac.abort();

console.log(e.listeners('test'));
console.log(e.listeners('error'));

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

The error listener should be removed, so console.log should print an empty array.

What do you see instead?

console.log prints an array with one listener.

Additional information

It seems the wrong listener is being removed in the following line:

eventTargetAgnosticRemoveListener(emitter, 'error', resolver);

The error listener is called errorListener, not resolver.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions