Skip to content

Cluster event listeners are attached even if not using clusters #155

Description

@SimenB

Because of https://github.com/siimon/prom-client/blob/426941fbc22433fff932d8f9fb09ebba4818f514/index.js#L24, https://github.com/siimon/prom-client/blob/426941fbc22433fff932d8f9fb09ebba4818f514/lib/cluster.js#L131-L170 is always ran

This results in a memory leak if require('prom-client'); is done multiples times and the require.cache is blown away, as might happen in tests.

I get the following after rerunning my tests, which blow away the require cache in order to mock a dep. (node:80194) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions