nx icon indicating copy to clipboard operation
nx copied to clipboard

regression: `run-commands` produces MaxListenersExceededWarning: Possible EventEmitter memory leak detected.

Open vire opened this issue 2 years ago • 4 comments

Current Behavior

I run my run-commands target and I can see in the console

(node:86270) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit

when I CTRL+C the command I get

^Cnode:internal/util:342
  throw new ERR_UNKNOWN_SIGNAL(signal);
  ^

TypeError [ERR_UNKNOWN_SIGNAL]: Unknown signal: 130
    at new NodeError (node:internal/errors:405:5)
    at convertToValidSignal (node:internal/util:342:9)
    at ChildProcess.kill (node:internal/child_process:489:5)
    at process.processExitListener (/Users/project/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/executors/run-commands/run-commands.impl.js:201:62)
    at process.emit (node:events:529:35)
    at process.exit (node:internal/process/per_thread:191:15)
    at process.<anonymous> (/Users/project/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/tasks-runner/forked-process-task-runner.js:345:21)
    at process.emit (node:events:529:35) {
  code: 'ERR_UNKNOWN_SIGNAL'
}

Node.js v18.20.1

Expected Behavior

No MaxListenersExceededWarning are present, CTRL+C does not throw

GitHub Repo

No response

Steps to Reproduce

n/a

Nx Report

Node   : 18.20.1
OS     : darwin-arm64
pnpm   : 8.15.6

nx                 : 18.2.2
@nx/js             : 18.2.2
@nx/jest           : 18.2.2
@nx/linter         : 18.2.2
@nx/eslint         : 18.2.2
@nx/workspace      : 18.2.2
@nx/cypress        : 18.2.2
@nx/devkit         : 18.2.2
@nx/esbuild        : 18.2.2
@nx/eslint-plugin  : 18.2.2
@nx/next           : 18.2.2
@nx/node           : 18.2.2
@nx/plugin         : 18.2.2
@nx/react          : 18.2.2
@nx/storybook      : 18.2.2
@nrwl/tao          : 18.2.2
@nx/web            : 18.2.2
@nx/webpack        : 18.2.2
typescript         : 5.4.3

Failure Logs

No response

Package Manager Version

[email protected]

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

possible regression of https://github.com/nrwl/nx/pull/20006

vire avatar Apr 05 '24 12:04 vire

@vire what command were you trying to run?

xiongemi avatar Apr 07 '24 22:04 xiongemi

@vire what command were you trying to run?

So I was running pnpm nx run myapp:start which is defined as

{
      "executor": "nx:run-commands",
      "options": {
        "commands": [
          "webpack serve --mode development --static",
          "nodemon --exec 'node --inspect=9229 --require ts-node/register ./server.ts' --watch ./  --ext .ts"
        ],
        "parallel": false,
        "color": true,
        "cwd": "apps/myapp"
      },
}

vire avatar Apr 08 '24 15:04 vire

i am able to replicate this issue. i think it is related to this ticket https://github.com/nrwl/nx/issues/22643. for now, maybe try set NX_NATIVE_COMMAND_RUNNER=false when running your commands.

need to do a proper fix.

xiongemi avatar Apr 09 '24 21:04 xiongemi

After pnpm nx migrate latest && pnpm nx migrate --run-migrations -> 18.3.4 the problem seems to be gone.

vire avatar Apr 30 '24 09:04 vire

closing this issue for now

xiongemi avatar May 10 '24 19:05 xiongemi

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar Jun 11 '24 00:06 github-actions[bot]