Skip to content

Move EventEmitter.defaultMaxListeners side effect out of configuration module #3615

@B4nan

Description

@B4nan

The Configuration module currently raises EventEmitter.defaultMaxListeners to 50 at import time:

https://github.com/apify/crawlee/blob/refactor/configuration-class-redesign/packages/core/src/configuration.ts#L10-L13

Crawlee attaches many listeners to shared EventEmitters (one per crawler/session/autoscaled pool), which can exceed Node's default limit of 10 and trigger spurious MaxListenersExceededWarning logs. The current placement at module top-level avoids the warnings, but it's an opaque global side effect of importing a value-object module — surprising and hard to discover.

Possible directions (to be explored later):

  • Set setMaxListeners(50, emitter) on the specific EventEmitter instances Crawlee owns, rather than mutating the global default.
  • Move the assignment into a lazily-invoked initialization path (e.g. crawler startup) so importing Configuration has no side effect.
  • Drop the bump entirely if real-world listener counts no longer hit the threshold.

Spun off from the Configuration class redesign PR review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions