Skip to content

MaxListenersExceededWarning when having 11+ content scripts defined #1204

Closed

Description

@vladgabriel

Describe the bug

When adding over 11 content scripts the following error is displayed:

(node:38511) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit

Reproduction

memory-setup.zip

Steps to reproduce

Run yarn install and yarn dev

System Info

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 76.14 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/.asdf/installs/nodejs/20.15.1/bin/node
    Yarn: 4.5.0 - ~/.asdf/installs/nodejs/20.15.1/bin/yarn
    npm: 10.7.0 - ~/.asdf/plugins/nodejs/shims/npm
    bun: 1.0.26 - ~/.bun/bin/bun
  Browsers:
    Chrome: 131.0.6778.86
    Chrome Canary: 133.0.6858.0
    Safari: 17.2.1

Used Package Manager

yarn

Validations

Activity

  1. added
    pending-triage
    on Nov 25, 2024
  2. aklinker1 commented on Nov 25, 2024

    @aklinker1
    Member

    I've noticed this as well, seems like each entrypoint group (build step) adds a listener... I assume because vite is adding it? Not 100% sure which dependency is causing it, but vite is my best guess.

    This only happens on node 20 and up.

  3. added and removed
    pending-triage
    on Nov 25, 2024
  4. aklinker1 commented on Nov 25, 2024

    @aklinker1
    Member

    This is caused by:

    const defaultExport =
    await wxt.builder.importEntrypoint<ContentScriptDefinition>(inputPath);

    Specifically when importing multiple entrypoints to extract their options during the build process, like content script matches, we use vite-node to import the TS file and do some preprocessing to speed things up.

    However, for every imported entrypoint, we have to create a Vite dev server, and that's where the warning comes from, the dev server setting up a listener to close the server when stopping the process.

    Fix is simple, only create a single dev server when importing entrypoint files, but refactoring the code to support that won't be... An easier fix is to import the files one by one, not in parallel, or setup a queue that only allows 9 imports be running at a time.

    But I'd rather refactor and get this done right. For now, you can ignore this warning. It shouldn't be causing any problems.

  5. self-assigned this
    on Nov 25, 2024
  6. added this to the v1.0 milestone on Nov 25, 2024
  7. added theissue type on Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions