MaxListenersExceededWarning: how to use "emitter.setMaxListeners" and avoid reaching the time limit?

Hi there,

I’m building jamstack.club with Hugo and Netlify, and I’m facing numerous errors MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit

The build then fails with the following error: Error running command: Command did not finish within the time limit

Here is the Nelify site name: jamstackclub.netlify.app
And the full build log:

6:58:29 AM: build-image version: 20e1f1f500e4cbad9ea8a99bd40807bef3093551 (focal)
6:58:29 AM: buildbot version: 00a030bf3c001e3c0d5d2d5931d77655af9653ed
6:58:29 AM: Fetching cached dependencies
6:58:29 AM: Failed to fetch cache, continuing with build
6:58:29 AM: Starting to prepare the repo for build
6:58:29 AM: No cached dependencies found. Cloning fresh repo
6:58:29 AM: git clone --filter=blob:none git@gitlab.com:Roneo/jamstack.club
6:58:31 AM: Preparing Git Reference refs/heads/main
6:58:42 AM: Starting to install dependencies
6:58:42 AM: Python version set to 3.8
6:58:42 AM: Attempting Ruby version 2.7.2, read from environment
6:58:43 AM: Using Ruby version 2.7.2
6:58:44 AM: Started restoring cached go cache
6:58:44 AM: Finished restoring cached go cache
6:58:44 AM: Installing Go version 1.16.5 (requested 1.16.5)
6:58:48 AM: go version go1.16.5 linux/amd64
6:58:48 AM: Using PHP version 8.0
6:58:48 AM: Installing Hugo 0.71.1
6:58:49 AM: Hugo Static Site Generator v0.71.1-A301F6B2/extended linux/amd64 BuildDate: 2020-05-25T09:18:12Z
6:58:50 AM: Downloading and installing node v16.20.2...
6:58:50 AM: Downloading https://nodejs.org/dist/v16.20.2/node-v16.20.2-linux-x64.tar.xz...
6:58:50 AM: Computing checksum with sha256sum
6:58:50 AM: Checksums matched!
6:58:52 AM: Now using node v16.20.2 (npm v8.19.4)
6:58:52 AM: Enabling Node.js Corepack
6:58:52 AM: Started restoring cached build plugins
6:58:52 AM: Finished restoring cached build plugins
6:58:52 AM: Started restoring cached corepack dependencies
6:58:52 AM: Finished restoring cached corepack dependencies
6:58:52 AM: No npm workspaces detected
6:58:52 AM: Started restoring cached node modules
6:58:52 AM: Finished restoring cached node modules
6:58:53 AM: Installing npm packages using npm version 8.19.4
6:59:02 AM: npm WARN deprecated puppeteer@5.5.0: < 19.4.0 is no longer supported
6:59:10 AM: added 352 packages, and audited 353 packages in 17s
6:59:10 AM: 94 packages are looking for funding
6:59:10 AM:   run `npm fund` for details
6:59:10 AM: 12 vulnerabilities (4 moderate, 7 high, 1 critical)
6:59:10 AM: To address issues that do not require attention, run:
6:59:10 AM:   npm audit fix
6:59:10 AM: To address all issues (including breaking changes), run:
6:59:10 AM:   npm audit fix --force
6:59:10 AM: Run `npm audit` for details.
6:59:10 AM: npm packages installed
6:59:10 AM: Install dependencies script success
6:59:10 AM: Starting build script
6:59:11 AM: Detected 2 framework(s)
6:59:11 AM: hugo at version unknown
6:59:11 AM: zola at version unknown
6:59:11 AM: Section completed: initializing
6:59:13 AM: ​
6:59:13 AM: Netlify Build                                                 
6:59:13 AM: ────────────────────────────────────────────────────────────────
6:59:13 AM: ​
6:59:13 AM: ❯ Version
6:59:13 AM:   @netlify/build 29.19.0
6:59:13 AM: ​
6:59:13 AM: ❯ Flags
6:59:13 AM:   baseRelDir: true
6:59:13 AM:   buildId: 64d5bff28e0cde28f3aa228f
6:59:13 AM:   deployId: 64d5bff28e0cde28f3aa2291
6:59:13 AM: ​
6:59:13 AM: ❯ Current directory
6:59:13 AM:   /opt/build/repo
6:59:13 AM: ​
6:59:13 AM: ❯ Config file
6:59:13 AM:   /opt/build/repo/netlify.toml
6:59:13 AM: ​
6:59:13 AM: ❯ Context
6:59:13 AM:   production
6:59:13 AM: ​
6:59:13 AM: ❯ Installing plugins
6:59:13 AM:    - @netlify/plugin-lighthouse@4.1.1
6:59:22 AM: ​
6:59:22 AM: ❯ Loading plugins
6:59:22 AM:    - @netlify/plugin-lighthouse@4.1.1 from Netlify app
6:59:22 AM: ​
6:59:22 AM: ❯ Outdated plugins
6:59:22 AM:    - @netlify/plugin-lighthouse@4.1.1: latest version is 5.0.0
6:59:22 AM:      To upgrade this plugin, please uninstall and re-install it from the Netlify plugins directory (https://app.netlify.com/plugins)
6:59:23 AM: ​
6:59:23 AM: build.command from netlify.toml                               
6:59:23 AM: ────────────────────────────────────────────────────────────────
6:59:23 AM: ​
6:59:23 AM: $ npm install && npm run deploy
6:59:24 AM: up to date, audited 353 packages in 623ms
6:59:24 AM: 94 packages are looking for funding
6:59:24 AM:   run `npm fund` for details
6:59:24 AM: 12 vulnerabilities (4 moderate, 7 high, 1 critical)
6:59:24 AM: To address issues that do not require attention, run:
6:59:24 AM:   npm audit fix
6:59:24 AM: To address all issues (including breaking changes), run:
6:59:24 AM:   npm audit fix --force
6:59:24 AM: Run `npm audit` for details.
6:59:25 AM: > deploy
6:59:25 AM: > node ./scripts/build.js --latest && hugo --minify
6:59:25 AM: Processing latest themes
6:59:25 AM: - Fetching Github Data
7:03:15 AM: ✔ Success - Fetching Github Data
7:03:15 AM: Writing /opt/build/repo/data/themes.json...
7:03:15 AM: - Fetching Stackbit Data
7:03:15 AM: ✔ Success - Fetching Stackbit Data
7:03:15 AM: Writing /opt/build/repo/data/stackbit.json...
7:05:39 AM: - Testing Demo URL's
✔ Success - Testing Demo URL's
- Capturing Screenshots
7:14:17 AM: (node:4288) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
7:14:17 AM: (Use `node --trace-warnings ...` to show where the warning was created)
7:14:17 AM: (node:4288) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
7:14:17 AM: (node:4288) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
7:14:17 AM: (node:4288) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit
7:30:39 AM: ✔ Success - Capturing Screenshots
7:30:39 AM: - Generating Thumbnails
7:30:40 AM: ✔ Success - Generating Thumbnails
7:30:40 AM: Writing /opt/build/repo/data/errors.json...
7:30:40 AM: Build Successful
7:30:40 AM: Error Log
7:30:46 AM: Building sites …
7:30:46 AM:                    |  EN
7:30:46 AM: -------------------+-------
7:30:46 AM:   Pages            | 2402
7:30:46 AM:   Paginator pages  |   95
7:30:46 AM:   Non-page files   |    2
7:30:46 AM:   Static files     | 3452
7:30:46 AM:   Processed images |    0
7:30:46 AM:   Aliases          |   67
7:30:46 AM:   Sitemaps         |    1
7:30:46 AM:   Cleaned          |    0
7:30:46 AM: Total in 5819 ms
7:30:46 AM: ​
7:30:46 AM: (build.command completed in 31m 22.4s)
7:30:46 AM: ​
7:30:46 AM: Functions bundling                                            
7:30:46 AM: ────────────────────────────────────────────────────────────────
7:30:46 AM: ​
7:30:46 AM: Packaging Functions from netlify/functions directory:
7:30:46 AM:  - submission-created.js
7:30:46 AM: ​
7:30:46 AM: ​
7:30:46 AM: (Functions bundling completed in 111ms)
7:30:46 AM: ​
7:30:46 AM: @netlify/plugin-lighthouse (onPostBuild event)                
7:30:46 AM: ────────────────────────────────────────────────────────────────
7:30:46 AM: ​
7:30:46 AM: Generating Lighthouse report. This may take a minute…
7:30:46 AM: Running Lighthouse on public/
7:30:46 AM: Serving and scanning site from directory public
7:31:07 AM: Lighthouse scores for public/
7:31:07 AM: - Performance: 94
7:31:07 AM: - Accessibility: 98
7:31:07 AM: - Best Practices: 92
7:31:07 AM: - SEO: 100
7:31:07 AM: - PWA: 70
7:31:07 AM: ​
7:31:07 AM: (@netlify/plugin-lighthouse onPostBuild completed in 20.5s)
7:31:07 AM: ​
7:31:07 AM: Deploy site                                                   
7:31:07 AM: ────────────────────────────────────────────────────────────────
7:31:07 AM: ​
7:31:07 AM: Starting to deploy site from 'public'
7:31:07 AM: Calculating files to upload
7:31:14 AM: 752 new files to upload
7:31:14 AM: 1 new functions to upload
7:31:14 AM: Starting to upload
7:31:14 AM: 10% uploaded
7:31:14 AM: 20% uploaded
7:31:14 AM: 30% uploaded
7:31:15 AM: 40% uploaded
7:31:17 AM: Starting post processing
7:31:17 AM: Post processing - HTML
7:31:17 AM: Failed during stage 'building site': Command did not finish within the time limit
7:31:17 AM: ---------------------------------------------------------------------
DEPRECATION NOTICE: Your site has asset optimization enabled. This feature will be at end of service on October 17, 2023.

After that date, your builds will continue to work but we won't minify or bundle the CSS and JS, and we won't optimize images.
To remove this warning, disable asset optimization in your site configuration:
https://app.netlify.com/sites/jamstackclub/configuration/deploys#asset-optimization


For more details, read our forum announcement:
https://answers.netlify.com/t/please-read-deprecation-of-post-processing-asset-optimization/96657
---------------------------------------------------------------------

7:31:15 AM: 50% uploaded
7:31:15 AM: 60% uploaded
7:31:15 AM: 70% uploaded
7:31:16 AM: 80% uploaded
7:31:16 AM: 90% uploaded
7:31:16 AM: 100% uploaded
7:31:16 AM: Section completed: deploying
7:31:16 AM: Site deploy was successfully initiated
7:31:16 AM: ​
7:31:16 AM: (Deploy site completed in 9.5s)
7:31:16 AM: ​
7:31:16 AM: Netlify Build Complete                                        
7:31:16 AM: ────────────────────────────────────────────────────────────────
7:31:16 AM: ​
7:31:16 AM: (Netlify Build completed in 32m 3.7s)
7:31:17 AM: Execution timed out after 32m6.560957766s
7:31:17 AM: Error running command: Command did not finish within the time limit
7:31:17 AM: Failing build: Failed to build site
7:31:17 AM: Finished processing build request in 32m48.78s

The build requires to fetch data from Github and generate a large amount of screenshots, and thus requires a large amount of time.

Should I try to fix the error about MaxListeners or is it a problem related to Netlify time limit?
How to avoid reaching this time limit, or increase the allowed build time?

I’ve increased the build’s time limit to an hour. Let’s see what changes does that make.

A build was successfull since then, thanks!
I’m marking this issue as solved, I’ll let you know if the same problem occurs again

Hi @hrishikesh , the same problem is back again, could you please have a look?

Here is the error message:

12:03:22 AM: (node:4416) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
12:03:22 AM: (Use `node --trace-warnings ...` to show where the warning was created)
12:03:22 AM: (node:4416) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit

Thank you!

Hi, I can increase your build timeout to 90 minute to see if that helps? Alternatively i’d recommend you look into optimising your build.