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

Nx executes targets out of order when overriding target in project.json #26929

Open
1 of 4 tasks
JacobLey opened this issue Jul 14, 2024 · 2 comments
Open
1 of 4 tasks
Assignees
Labels
scope: core core nx functionality type: bug

Comments

@JacobLey
Copy link
Contributor

Current Behavior

When defining a task graph that has tasks defined in both nx.json and project.json, it is expected that the dependsOn is inherited by the nx.json implemention if not otherwise overridden by project.json.

In fact, this is consistent with the task graph displayed by nx graph.

However, when overriding targets in project.json, the dependency order is not always respected. This conflicts with the graph which claims it still is.

Create two "meta-targets" build and test. These are simply nx:noop executors that point to a series of real targets for user convenicence.

Building is bound to a single target build-impl.
Testing is bound to two targets test-impl and report-impl. These both depend on build being complete.

For simplicity, these default implementations are a 1 second wait, then logging their name.

report-impl is overwritten in project.json to just immediately log the name.

Inspect the task graph nx graph appears to confirm that a test command would:

  1. Run build
  2. Run test
  3. Generate report

Running nx run foo:test actually results in the following logs:

  1. REPORT

  2. BUILD

  3. TEST

The report step is executed immediately, despite the dependency graph claiming otherwise.

Expected Behavior

Running nx run foo:test should result in the following logs:

  1. BUILD

  2. TEST

  3. REPORT

GitHub Repo

https://github.com/JacobLey/issue-recreator/tree/nx-task-dependency-order

Steps to Reproduce

  1. Set up package as described above, or in example repo's README
  2. pnpm i
  • Install necessary packages
  1. Run nx graph
  • Confirm that the report-impl task has both build-imp and test-impl as dependencies
  1. nx run foo:test
  • Inspect the console output shows REPORT before BUILD (and TEST), meaning that it did not properly block on a dependency.

Nx Report

Node   : 22.4.1
OS     : linux-arm64
pnpm   : 9.5.0

nx (global)  : 19.4.3
nx           : 19.4.3
@nrwl/tao    : 19.4.3

Failure Logs

No failure logs, just unexpected execution order.

This _can_ easily induce unrelated failure logs, like in the example above trying to execute tests before the build even starts.

Package Manager Version

pnpm 9.5.0

Operating System

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

Additional Information

I've tried reducing the example case and don't always see it, but definitely experiencing it 10-fold in my live repo.

Attached is image of nx graph. While the dependency explanation above may seem a bit unclear, hopefully it is fairly obvious here that a fairly linear execution of tasks is expected here. I agree with the output provided by nx graph, it is the actual execution of run that is out of order.
Screenshot 2024-07-13 at 9 54 49 PM

@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label Jul 16, 2024
JacobLey added a commit to JacobLey/leyman that referenced this issue Jul 23, 2024
@jonathanmorley
Copy link
Contributor

This appears to have been introduced in 19.1.1

@jonathanmorley
Copy link
Contributor

I suspect its caused by this #26033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: core core nx functionality type: bug
Projects
None yet
Development

No branches or pull requests

4 participants