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

waitUntilTargets not working as expected #30033

Open
1 of 4 tasks
TroutZen opened this issue Feb 13, 2025 · 0 comments
Open
1 of 4 tasks

waitUntilTargets not working as expected #30033

TroutZen opened this issue Feb 13, 2025 · 0 comments

Comments

@TroutZen
Copy link

Current Behavior

Have a monorepo with a fairly simple config in a package called "app" that depends on config:dev for the "dev" target.

Per https://nx.dev/recipes/node/wait-for-tasks#waituntiltargets it seems that the expected behavior would be that running

nx dev app

would execute the dev target on the config package and then execute the target dev in the app package. Currently I get an error that required property 'buildTarget' is missing, however, in this instance I don't need a build target. Nor is one specified in the example.

Required property 'buildTarget' is missing
// packages/app
 
{
  "$schema": "../../node_modules/nx/schemas/nx-schema.json",
  "targets": {
      "dev": {
        "executor": "@nx/js:node",
        "options": {
          "waitUntilTargets": ["config:dev"]
        }
      }
    }
  }

When I do give it a build target just to see what happens

"dev": {
        "executor": "@nx/js:node",
        "options": {
          "buildTarget": "app:build",
          "waitUntilTargets": ["config:dev"]
        }
      }

nx runs config:dev, which is a long running process and never executes app:build

I should also note that I am attempting to use this API to handle targets that are dependent on other targets with long running processes, i.e. start some process after another long running process starts, which is a discussion here: #16688

Expected Behavior

  • buildTarget should be optional
  • package app's "dev" script defined in package.json should be executed after running "config:dev" and waiting for output

GitHub Repo

https://github.com/TroutZen/nx_wait_until_targets_repo_1

Steps to Reproduce

Can also be found in project README.md

Repro Steps

  • run pnpm install @ root of project
  • nx dev app from root of project
  • should see error that buildTarget is required
  • now go to packages/app and delete project.json and rename _project.json to project.json
  • run nx dev app again
  • would expect to see starting app... from packages/app "dev" script, but given dependency on buildTarget it tries to run the build target which seems should be optional

Nx Report

Node           : 22.13.1
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.15.4

nx             : 20.4.3
@nx/js         : 20.4.3
@nx/workspace  : 20.4.3
@nx/devkit     : 20.4.3
typescript     : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant