You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MaxListenersExceededWarning when having 11+ content scripts defined #1204
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
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.
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.
Activity
aklinker1 commentedon Nov 25, 2024
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.
aklinker1 commentedon Nov 25, 2024
This is caused by:
wxt/packages/wxt/src/core/utils/building/find-entrypoints.ts
Lines 360 to 361 in 5a3790a
Specifically when importing multiple entrypoints to extract their options during the build process, like content script
matches, we usevite-nodeto 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.