nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.52k stars 2.35k forks source link

run many doesn't work with nest plugin as expected #28439

Open dancespiele opened 1 week ago

dancespiele commented 1 week ago

Current Behavior

I have a mono repo using nx with the plugin @nx/nest and my project have this configuration:

{
  "name": "app",
  "$schema": "../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "app/src",
  "projectType": "application",
  "implicitDependencies": ["!config", "!helpers", "!entities"],
  "tags": [],
  "targets": {
    "serve": {
      "executor": "@nx/js:node",
      "defaultConfiguration": "development",
      "dependsOn": ["build"],
      "options": {
        "buildTarget": "app:build",
        "runBuildTargetDependencies": false,
        "args": ["server"]
      },
      "configurations": {
        "development": {
          "buildTarget": "app:build:development"
        },
        "production": {
          "buildTarget": "app:build:production"
        }
      }
    },
    "subscribe": {
      "executor": "@nx/js:node",
      "defaultConfiguration": "development",
      "dependsOn": ["build"],
      "options": {
        "buildTarget": "app:build",
        "runBuildTargetDependencies": false,
        "inspect": true,
        "args": ["subscribe"]
      },
      "configurations": {
        "development": {
          "buildTarget": "app:build:development"
        },
        "production": {
          "buildTarget": "app:build:production"
        }
      }
    }
  }
}

run-many only works with serve, with subscribe or if I rename serve it hangs but everything works with the standard command nx run

Expected Behavior

run many should work not only with task called serve

GitHub Repo

minimal bug reproduction

Steps to Reproduce

  1. Create a app inside of a monorepo handle by nx with nx g @nx/nest:app app
  2. Rename task serve to server or create a new task in project.json of the installed app
  3. try nx run-many -t server subscribe -p app
  4. Runner will hang

Nx Report

Node           : 18.20.3
OS             : linux-x64
Native Target  : x86_64-linux
yarn           : 1.22.22

nx (global)        : 19.6.5
nx                 : 19.8.2
@nx/js             : 19.8.2
@nx/jest           : 19.8.2
@nx/linter         : 19.8.2
@nx/eslint         : 19.8.2
@nx/workspace      : 19.8.2
@nx/devkit         : 19.8.2
@nx/esbuild        : 19.8.2
@nx/eslint-plugin  : 19.8.2
@nx/nest           : 19.8.2
@nx/node           : 19.8.2
@nrwl/tao          : 19.8.2
@nx/web            : 19.8.2
@nx/webpack        : 19.8.2
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

dancespiele commented 1 week ago

The same issue with the version 20.0.1

dancespiele commented 1 week ago

This is a work around which shouldn't be the final solution (nx developers should fix the executor @nx/js:node in order to run run-many without hang). As I mentioned single runs works and @nx/js:node has the option waitUntilTargets which accept an array, there you need to add all the tasks that will execute in parallel for example:

{
  "name": "app",
  "$schema": "../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "app/src",
  "projectType": "application",
  "implicitDependencies": ["!config", "!helpers", "!entities"],
  "tags": [],
  "targets": {
    "serve": {
      "executor": "@nx/js:node",
      "defaultConfiguration": "development",
      "dependsOn": ["build"],
      "options": {
        "buildTarget": "app:build",
        "runBuildTargetDependencies": false,
        "args": ["server"],
        "waitUntilTarget": ["app:subscribe"]
      },
      "configurations": {
        "development": {
          "buildTarget": "app:build:development"
        },
        "production": {
          "buildTarget": "app:build:production"
        }
      }
    },
    "subscribe": {
      "executor": "@nx/js:node",
      "defaultConfiguration": "development",
      "dependsOn": ["build"],
      "options": {
        "buildTarget": "app:build",
        "runBuildTargetDependencies": false,
        "inspect": true,
        "args": ["subscribe"]
      },
      "configurations": {
        "development": {
          "buildTarget": "app:build:development"
        },
        "production": {
          "buildTarget": "app:build:production"
        }
      }
    }
  }
}