Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting MaxListenersExceededWarning and "ELIFECYCLE  Command failed" error #54

Open
ax-at opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ax-at
Copy link

ax-at commented Apr 19, 2024

When running below command in my "TurboRepo monorepo", which will run "turbowatch" in 8 packages.

pnpm exec turbowatch '**/turbowatch.ts'

I get below warning:

[turbowatch] running turbowatch without logging enabled; set ROARR_LOG=true to enable logging. Install @roarr/cli to pretty-print logs.
(node:78062) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

and further builds fail continuously for packages with below error:

ELIFECYCLE  Command failed.

But when I run with below command, which runs "turbowatch" only for 4 out of 8 packages:

pnpm exec turbowatch "./packages/logging/turbowatch.ts" "./packages/validators/turbowatch.ts" "./packages/trpc/turbowatch.ts" "./packages/schema/turbowatch.ts"

It seems to work fine.

System

  • Node.js = v20.10.0
  • PNPM = v8.15.6

Expected Behavior

TurboWatch should have been able to build all packages.

Current Behavior

The command fails with below warning and error:

[turbowatch] running turbowatch without logging enabled; set ROARR_LOG=true to enable logging. Install @roarr/cli to pretty-print logs.
(node:78062) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

Further builds fail continuously for packages with below error:

ELIFECYCLE  Command failed.

Possible Solution

May be using events.setMaxListeners() to increase the limit, but not sure how to do that.

Steps to Reproduce

Run turbowatch in a turborepo having more than 8 packages and each package having a turbowatch.ts as below:

import { defineConfig } from "turbowatch";

export default defineConfig({
  project: __dirname,
  triggers: [
    {
      expression: [
        "anyof",
        [
          "allof",
          ["dirname", "node_modules"],
          ["dirname", "dist"],
          ["anyof", ["match", "*.ts", "basename"]],
        ],
        [
          "allof",
          ["not", ["dirname", "node_modules"]],
          ["dirname", "src"],
          ["anyof", ["match", "*.ts", "basename"]],
        ],
      ],
      name: "build",
      onChange: async ({ spawn }) => {
        await spawn`pnpm run build`;
      },
      persistent: false,
    },
  ],
});

Logs

{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"0","time":1713521768568,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"1","time":1713521768616,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (f81aaf3f): initial run...","sequence":"2","time":1713521768616,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (f81aaf3f): started task","sequence":"3","time":1713521768621,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"4","time":1713521768621,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"5","time":1713521768622,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"6","time":1713521768660,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (840d41b0): initial run...","sequence":"7","time":1713521768660,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (840d41b0): started task","sequence":"8","time":1713521768660,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"9","time":1713521768661,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"10","time":1713521768661,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"11","time":1713521768729,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (2c181ad0): initial run...","sequence":"12","time":1713521768729,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (2c181ad0): started task","sequence":"13","time":1713521768729,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"14","time":1713521768729,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"15","time":1713521768730,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"16","time":1713521768764,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (49cdb18a): initial run...","sequence":"17","time":1713521768764,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (49cdb18a): started task","sequence":"18","time":1713521768765,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"19","time":1713521768765,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"20","time":1713521768766,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"21","time":1713521768853,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (3b9c8f8e): initial run...","sequence":"22","time":1713521768853,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (3b9c8f8e): started task","sequence":"23","time":1713521768854,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"24","time":1713521768854,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"25","time":1713521768855,"version":"2.0.0"}
(node:85440) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"26","time":1713521769198,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (01496d95): initial run...","sequence":"27","time":1713521769198,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (01496d95): started task","sequence":"28","time":1713521769199,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"29","time":1713521769199,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"30","time":1713521769200,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"31","time":1713521769977,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (bd4fa515): initial run...","sequence":"32","time":1713521769978,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (bd4fa515): started task","sequence":"33","time":1713521769978,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"34","time":1713521769978,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"TurboWatcher","logLevel":30},"message":"using native ChokidarWatcher","sequence":"35","time":1713521769979,"version":"2.0.0"}
f81aaf3f > 
f81aaf3f > > @acme/logging@0.2.0 build /home/some/directory/some-project/packages/logging
f81aaf3f > > tsup src/index.ts --format cjs,esm --dts
f81aaf3f > CLI Building entry: src/index.ts
f81aaf3f > CLI Using tsconfig: tsconfig.json
f81aaf3f > CLI tsup v8.0.1
f81aaf3f > CLI Target: es2022
f81aaf3f > CJS Build start
f81aaf3f > ESM Build start
f81aaf3f > ESM dist/index.mjs 234.00 B
f81aaf3f > ESM ⚡️ Build success in 69ms
f81aaf3f > CJS dist/index.js 1.84 KB
f81aaf3f > CJS ⚡️ Build success in 69ms
840d41b0 > 
840d41b0 > > @acme/validators@0.2.0 build /home/some/directory/some-project/packages/validators
840d41b0 > > tsup src/index.ts --format cjs,esm --dts
840d41b0 > CLI Building entry: src/index.ts
840d41b0 > CLI Using tsconfig: tsconfig.json
840d41b0 > CLI tsup v8.0.1
840d41b0 > CLI Target: es2022
840d41b0 > CJS Build start
840d41b0 > ESM Build start
840d41b0 > CJS dist/index.js 1.25 KB
840d41b0 > CJS ⚡️ Build success in 71ms
840d41b0 > ESM dist/index.mjs 189.00 B
840d41b0 > ESM ⚡️ Build success in 72ms
2c181ad0 > 
2c181ad0 > > @acme/trpc@0.2.0 build /home/some/directory/some-project/packages/trpc
2c181ad0 > > tsup src/index.ts --format cjs,esm --dts
2c181ad0 > CLI Building entry: src/index.ts
2c181ad0 > CLI Using tsconfig: tsconfig.json
2c181ad0 > CLI tsup v8.0.1
2c181ad0 > CLI Target: es2022
2c181ad0 > CJS Build start
2c181ad0 > ESM Build start
2c181ad0 > ESM dist/index.mjs 2.26 KB
2c181ad0 > ESM ⚡️ Build success in 123ms
2c181ad0 > CJS dist/index.js 3.55 KB
2c181ad0 > CJS ⚡️ Build success in 125ms
49cdb18a > 
49cdb18a > > @acme/schema@0.2.0 build /home/some/directory/some-project/packages/schema
49cdb18a > > tsup src/index.ts --format cjs,esm --dts
49cdb18a > CLI Building entry: src/index.ts
49cdb18a > CLI Using tsconfig: tsconfig.json
49cdb18a > CLI tsup v8.0.1
49cdb18a > CLI Target: es2022
49cdb18a > CJS Build start
49cdb18a > ESM Build start
49cdb18a > CJS dist/index.js 17.41 KB
49cdb18a > CJS ⚡️ Build success in 94ms
49cdb18a > ESM dist/index.mjs 13.79 KB
49cdb18a > ESM ⚡️ Build success in 99ms
3b9c8f8e > 
3b9c8f8e > > @acme/database-legacy@0.2.0 build /home/some/directory/some-project/packages/database-legacy
3b9c8f8e > > tsup src/index.ts --format cjs,esm --dts
3b9c8f8e > CLI Building entry: src/index.ts
3b9c8f8e > CLI Using tsconfig: tsconfig.json
3b9c8f8e > CLI tsup v8.0.1
3b9c8f8e > CLI Target: es2022
3b9c8f8e > CJS Build start
3b9c8f8e > ESM Build start
3b9c8f8e > CJS dist/index.js 5.60 KB
3b9c8f8e > CJS ⚡️ Build success in 148ms
3b9c8f8e > ESM dist/index.mjs 3.59 KB
3b9c8f8e > ESM ⚡️ Build success in 148ms
01496d95 > 
01496d95 > > @acme/features@0.2.0 build /home/some/directory/some-project/packages/features
01496d95 > > tsup src/index.ts --format cjs,esm --dts
01496d95 > CLI Building entry: src/index.ts
01496d95 > CLI Using tsconfig: tsconfig.json
01496d95 > CLI tsup v8.0.1
01496d95 > CLI Target: es2022
01496d95 > CJS Build start
01496d95 > ESM Build start
f81aaf3f > DTS Build start
840d41b0 > DTS Build start
2c181ad0 > DTS Build start
49cdb18a > DTS Build start
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"triggering initial runs","sequence":"36","time":1713521771595,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"start (7b277c12): initial run...","sequence":"37","time":1713521771595,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"start (7b277c12): started task","sequence":"38","time":1713521771596,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"watch","logLevel":30},"message":"ready for file changes","sequence":"39","time":1713521771596,"version":"2.0.0"}
3b9c8f8e > DTS Build start
bd4fa515 > 
bd4fa515 > > @acme/api@0.2.0 build /home/some/directory/some-project/packages/api
bd4fa515 > > tsup src/index.ts --format cjs,esm --dts
bd4fa515 > CLI Building entry: src/index.ts
bd4fa515 > CLI Using tsconfig: tsconfig.json
bd4fa515 > CLI tsup v8.0.1
bd4fa515 > CLI Target: es2022
bd4fa515 > CJS Build start
bd4fa515 > ESM Build start
01496d95 > ESM dist/index.mjs 55.20 KB
01496d95 > ESM ⚡️ Build success in 400ms
01496d95 > CJS dist/index.js 57.77 KB
01496d95 > CJS ⚡️ Build success in 403ms
01496d95 > DTS Build start
bd4fa515 > CJS dist/index.js 7.70 KB
bd4fa515 > CJS ⚡️ Build success in 158ms
bd4fa515 > ESM dist/index.mjs 6.30 KB
bd4fa515 > ESM ⚡️ Build success in 159ms
bd4fa515 > DTS Build start
7b277c12 > 
7b277c12 > > @acme/server@0.2.0 start /home/some/directory/some-project/apps/server
7b277c12 > > pnpm with-env nest start
7b277c12 > 
7b277c12 > > @acme/server@0.2.0 with-env /home/some/directory/some-project/apps/server
7b277c12 > > dotenv -e ../../.env -- "nest" "start"
f81aaf3f > DTS ⚡️ Build success in 6052ms
f81aaf3f > DTS dist/index.d.ts  166.00 B
f81aaf3f > DTS dist/index.d.mts 166.00 B
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (f81aaf3f): completed task","sequence":"40","time":1713521776941,"version":"2.0.0"}
840d41b0 > DTS ⚡️ Build success in 6267ms
840d41b0 > DTS dist/index.d.ts  403.00 B
840d41b0 > DTS dist/index.d.mts 403.00 B
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (840d41b0): completed task","sequence":"41","time":1713521777270,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (3b9c8f8e): aborting task","sequence":"42","time":1713521777840,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (3b9c8f8e): waiting for task to abort","sequence":"43","time":1713521777856,"version":"2.0.0"}
2c181ad0 > DTS ⚡️ Build success in 6763ms
2c181ad0 > DTS dist/index.d.ts  5.72 KB
2c181ad0 > DTS dist/index.d.mts 5.72 KB
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (2c181ad0): completed task","sequence":"44","time":1713521777933,"version":"2.0.0"}
3b9c8f8e >  ELIFECYCLE  Command failed.
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":40},"message":"build (3b9c8f8e): task aborted","sequence":"45","time":1713521777967,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (3b9c8f8e): completed task","sequence":"46","time":1713521777967,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20,"files":["/home/some/directory/some-project/packages/database-legacy/node_modules/@acme/logging/dist/index.d.ts"]},"message":"build (b0f303be): 1 file changed","sequence":"47","time":1713521777967,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (b0f303be): started task","sequence":"48","time":1713521777968,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20},"message":"all processes terminated","sequence":"49","time":1713521778171,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"createSpawn","logLevel":20},"message":"task 3b9c8f8e was killed","sequence":"50","time":1713521778171,"version":"2.0.0"}
49cdb18a > DTS ⚡️ Build success in 7641ms
49cdb18a > DTS dist/index.d.ts  59.31 KB
49cdb18a > DTS dist/index.d.mts 59.31 KB
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (49cdb18a): completed task","sequence":"51","time":1713521778737,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20,"files":["/home/some/directory/some-project/packages/trpc/node_modules/@acme/logging/dist/index.d.ts"]},"message":"build (c081dd3c): 1 file changed","sequence":"52","time":1713521778796,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"build (c081dd3c): started task","sequence":"53","time":1713521778796,"version":"2.0.0"}
^C{"context":{"package":"turbowatch","namespace":"turbowatch","logLevel":40},"message":"received SIGINT; gracefully terminating","sequence":"54","time":1713521779088,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85859},"message":"process already terminated","sequence":"55","time":1713521779159,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85772},"message":"process already terminated","sequence":"56","time":1713521779162,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85758},"message":"process already terminated","sequence":"57","time":1713521779165,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85761},"message":"process already terminated","sequence":"58","time":1713521779165,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85793},"message":"process already terminated","sequence":"59","time":1713521779165,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85532},"message":"process already terminated","sequence":"60","time":1713521779168,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85640},"message":"process already terminated","sequence":"61","time":1713521779168,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85641},"message":"process already terminated","sequence":"62","time":1713521779168,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"killPsTree","logLevel":20,"pid":85739},"message":"process already terminated","sequence":"63","time":1713521779168,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"start (7b277c12): re-running because the trigger is persistent","sequence":"64","time":1713521779171,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":40},"message":"start (7b277c12): task aborted","sequence":"65","time":1713521779171,"version":"2.0.0"}
{"context":{"package":"turbowatch","namespace":"subscribe","logLevel":20},"message":"start (7b277c12): completed task","sequence":"66","time":1713521779171,"version":"2.0.0"}
@ax-at ax-at added the bug Something isn't working label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant