Skip to content

readyWhen not honored on continuous target #31496

Description

@techfg

Current Behavior

When a target relies on a continuous target that is configured with readyWhen, the readyWhen configuration of the continuous target is not honored and the specified target executes immediately, before the continuous target has met the readyWhen conditions.

Use Case: Test suite relies on dev target but must wait for dev to be ready before it starts to execute tests. With dev configured as continuous, there needs to be a way to ensure that tests don't start until dev is fully ready. The only way that it appears nx supports this configuration is via readyWhen but readyWhen is ignored when continuous is configured.

Expected Behavior

readyWhen should be honored for continuous targets and targets that depend on the continuous target not started until readyWhen conditions are met.

GitHub Repo

https://github.com/techfg/nx-21-continuous-tasks-repros

Steps to Reproduce

  1. git clone https://github.com/techfg/nx-21-continuous-tasks-repros.git
  2. npx nx run waitForDevReadyWhenContinuous

Actual Behavior: waitForDevReadyWhenContinuous starts immediately and does not wait until devReadyWhenContinuous has met its readyWhen conditions

Nx Report

Node           : 22.16.0
OS             : linux-x64
Native Target  : x86_64-linux
npm            : 10.9.2

nx             : 21.1.3
@nx/js         : 21.1.3
@nx/workspace  : 21.1.3
@nx/devkit     : 21.1.3
typescript     : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
---------------------------------------
Cache Usage: 0.00 B / 100.69 GB

Failure Logs

Package Manager Version

npm 10.9.2

Operating System

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

Additional Information

  • The doc description for readyWhen is somewhat contradictory to the name of the option so possibly I am misunderstanding the intent/purpose of this option. The docs use the terminology done, but the name of the option is readyWhen so it's not 100% clear if this is supposed to indicate when a task is "done" or "ready". Given the name, the assumption is that when it's "ready" which would align with the use case described above as it relates to continuous tasks.
  • Running npx nx run waitForDevReadyWhen waits for devReadyWhen as expected since devReadyWhen is not configured as continuous
  • Related nx:run-commands does not honor readyWhen when only one command configured #31495
  • Workaround is to have a separate non-continuous target waitForDev that dependsOn the continuous target dev and "polls" (e.g. checks a /health route for 200) and have the test target dependsOn waitForDev instead of dev. While this works as needed, it's all unnecessary configuration and readyWhen should be honored regardless of continuous configuration value (or another stock method to support this incredibly likely common use case added).

Metadata

Metadata

Assignees

Labels

No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions