nx icon indicating copy to clipboard operation
nx copied to clipboard

Dependent job run earlier than should be allowed

Open JakeGinnivan opened this issue 3 years ago • 0 comments
trafficstars

Current Behavior

When having multiple levels of dependencies it's possible for tasks to run earlier than they are allowed to.

Expected Behavior

If a task dependsOn another task, it should not run before the dependent task completes.

Steps to Reproduce

There are 3 apps, cms, api and web.

Then 4 infrastructure projects (terraform) with apply tasks. I am using NX to ensure that the artifacts terraform will be deploying as part of it's infra as code apply command.

image

https://github.com/JakeGinnivan/nx-concurrency-bug

Run pnpm nx apply web-infra --output-style stream --environment dev --skip-nx-cache

Failure Logs

The above command gives the following output

nx-concurrency-bug> pnpm nx apply web-infra --output-style stream --environment dev --skip-nx-cache --with-deps                                                                                                                                     14:11:59

 >  NX   Running target apply for project web-infra and 7 task(s) it depends on

 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

> nx run core-infra:apply


> nx run cms:build

[core-infra     ] running core-infra apply
[cms            ] running cms build
[cms            ] finished cms build

> nx run api:build

[api            ] running api build
[api            ] finished api build

> nx run api:docker-build


> nx run web:build

[web            ] running web build
[api            ] running api docker-build
[web            ] finished web build
[api            ] finished api docker-build

> nx run api-infra:apply --environment=dev --with-deps=true

[api-infra      ] running api-infra apply --environment=dev --with-deps=true
[core-infra     ] finished core-infra apply

> nx run cms-infra:apply

[cms-infra      ] running cms-infra apply
[api-infra      ] finished api-infra apply --environment=dev --with-deps=true
[cms-infra      ] finished cms-infra apply

> nx run web-infra:apply --environment=dev --with-deps=true

[web-infra      ] running web-infra apply --environment=dev --with-deps=true
[web-infra      ] finished web-infra apply --environment=dev --with-deps=true

 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target apply for project web-infra

When api:docker-build finishes, the api-infra:apply task kicks off.

This shouldn't be allowed as the graph for api-infra has a dependency on core-infra which has not yet finished.

Environment

 >  NX   Report complete - copy this into the issue template

   Node : 16.16.0
   OS   : darwin arm64
   pnpm : 7.9.0
   
   nx : 14.5.1
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.5.1
   @nrwl/eslint-plugin-nx : 14.5.1
   @nrwl/express : Not Found
   @nrwl/jest : 14.5.1
   @nrwl/js : Not Found
   @nrwl/linter : 14.5.1
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/workspace : 14.5.1
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:

JakeGinnivan avatar Aug 09 '22 06:08 JakeGinnivan