Skip to content

TypeError: EventEmitter, setMaxListeners, Symbol #9003

Closed
@Daeren

Description

@Daeren
  • Version: 6.7.0
  • Platform: Win 10 @ 64-bit

Expected Behavior

(node:3712) Warning: Possible EventEmitter memory leak detected.
2 Symbol("X") listeners added. Use emitter.setMaxListeners() to increase limit

Current Behavior

TypeError: Cannot convert a Symbol value to a string

Steps to Reproduce

"use strict";

const EventEmitter = require("events");

const ev    = new EventEmitter(),
      sym   = Symbol("X"); // "X";

ev
    .setMaxListeners(1)
    .on(sym, console.log)
    .on(sym, console.log)
    .emit(sym, 200);

Stack trace

events.js:260
                            `${existing.length} ${type} listeners added. ` +
                                                  ^

TypeError: Cannot convert a Symbol value to a string
    at _addListener (events.js:260:51)
    at EventEmitter.addListener (events.js:275:10)
    at Object.<anonymous> (J:\main.js:13:6)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    eventsIssues and PRs related to the events subsystem / EventEmitter.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions