Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

events: EventEmitter prototypal inheritance has side effects #7157

@bnoordhuis

Description

@bnoordhuis
$ node
> events
{ usingDomains: false,
  EventEmitter: { [Function: EventEmitter] listenerCount: [Function] } }
> function F() { events.EventEmitter.call(this) }
undefined
> F.prototype = new events.EventEmitter;
{ domain: null,
  _events: {},
  _maxListeners: 10 }
> var a = new F, b = new F
undefined
> a.on('x', function no() {})
{ domain: null,
  _events: { x: [Function: no] },
  _maxListeners: 10 }
> b._events
{ x: [Function: no] }

It's because of commit 45a13d9 introduced in v0.8.14. The commit log is light on details and doesn't reference a bug number so I can only guess what it's trying to fix. At any rate, the current behavior seems pretty broken to me.

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