Skip to content
GitHubBlueskydev.toRSS

04Run tasks

Explore the task graph

See which tasks wait on which, and why. Ask vx for the plan of a run: nothing runs.

Terminal window
vx run build test --all --dry --format json > plan.json
Read

Here is that plan from the running tasks workspace, after one edit to packages/ui/src/index.ts. Its two tasks are build and test. Click any box.

Run vx run build --all --dry --format json > plan.json in your workspace. With JavaScript on, paste it here to browse what each task waits on and why.

The task you picked is in bold. Above it: what it waits on. Below it: what waits on it.

  • Green: cached. The run restores it.
  • Cyan: run. It runs.

The terminal uses the same two colours.

Check yourself Nothing in packages/web changed. Why is @demo/web#build cyan?

It waits on @demo/ui#build, which the edit gave a new key. A task’s key holds the keys of the tasks it waits on, so @demo/web#build gets a new one too. @demo/api stays green.

You can now see what a task waits on, what waits on it, and which tasks a run would skip.

Drop --format json and vx prints the same plan as a table:

Terminal window
vx run build test --all --dry
one file edited in @demo/ui
Plan 8 status cache usual blocks worker task
run miss ~163ms 0 local @demo/admin#build
run miss ~185ms 4 local @demo/ui#build
cached local — 0 local @demo/api#build
run miss ~164ms 0 local @demo/web#build
run miss ~344ms 0 local @demo/admin#test
cached local — 0 local @demo/api#test
run miss ~468ms 0 local @demo/ui#test
run miss ~353ms 0 local @demo/web#test
tasks 8 planned · 2 cache hits (2 local) · 6 would run
predicted ~538ms wall · ~1.68s total execution

Read blocks: how many tasks wait on that row. @demo/ui#build blocks 4, so while it runs, four tasks wait.

usual is the task’s usual run time from past runs; a cached row has none. worker is where it would run: local is this machine.

You can now spot the task that holds up the most work, before you run anything.

  1. Write your plan to a file, from your workspace root:

    Terminal window
    vx run build --all --dry --format json > plan.json
  2. Under the picture, open Open your own plan and drop plan.json in the box. Or paste it, then press Read plan.

  3. Type a task, such as web#build. Part of a name is enough.

You can now draw any task of your own workspace and walk its graph box by box.

Type a task in Task and another in waits on?. The path between them lights up.

Pick @demo/web#test and ask if it waits on @demo/ui#build:

Terminal window
@demo/web#test → @demo/ui#build

One arrow: the test waits on the build of the kit it imports. A longer path lists every task between the two.

Each arrow is one line of config. build in dependsOn is a task of the same project; ^build is build in each package this one depends on (Tasks).

Check yourself Which config line made the arrow @demo/web#test → @demo/ui#build?

dependsOn: ['^build'] on test in packages/web/vx.config.ts. @demo/web depends on @demo/ui in its package.json, so ^build means @demo/ui#build.

You can now trace any wait back to the dependsOn line that made it.

PatternsAsk the plan from a script

The plan is plain JSON, so jq answers questions the picture does not:

Terminal window
jq '[.tasks[] | select(.cacheStatus == "miss") | .id]' plan.json
the demo plan
[
"@demo/admin#build",
"@demo/ui#build",
"@demo/web#build",
"@demo/admin#test",
"@demo/ui#test",
"@demo/web#test"
]

predicted.criticalPath is the longest path of tasks that run, by their usual times. wallMs is how long it takes:

Terminal window
jq '.predicted' plan.json
the demo plan
{
"wallMs": 538,
"workMs": 1677,
"unknownCount": 0,
"criticalPath": [
"@demo/ui#build",
"@demo/web#test"
]
}

Make a task on that path faster and the whole run ends sooner. Speed up one off it and the run does not change.

Any run selection gives a plan of the same shape. Explore it the same way:

Terminal window
vx run build --filter @demo/web... --dry --format json > plan.json
vx run test --affected --dry --format json > plan.json

--filter @demo/web... is @demo/web and everything it uses. --affected is what your changes reach, and each task says why in affected.

You can now answer “what runs, what is slow, what did my change touch” from one file.

DetailsEvery field in the plan

The plan’s schema ships with vx as schemas/plan.json. A field marked sometimes is left out when it has no value.

Field Holds
tasks every task the run would start, one object each
predicted sometimes: the run’s times, from the tasks’ history
affectedBase sometimes: under --affected, the git ref the change was measured from
downloadDowngrades sometimes: under --cache-download, each task whose outputs vx must still download, as taskId and reason

Each task:

Field Holds
id project#task, such as @demo/web#build
project, task the two halves of id
hash the task’s cache key; empty when the run computes none
cacheStatus what the run would do (table below)
deps the ids it waits on directly
p50Ms sometimes: its usual run time in milliseconds, from history
executor sometimes: where it would run, when the workspace has more than one place to run tasks
download sometimes: deferred when its outputs would stay in the remote cache (--cache-download)
description sometimes: the task’s description
otherPlatform sometimes: a skipped task’s needs (its exec.platforms) and this machine’s host
blockedBy sometimes: a skipped task’s root, the task it waits on that needs another platform
affected sometimes: under --affected, why the task is in the run: kind, and file, project or via

predicted:

Field Holds
wallMs how long the run would take, start to end
workMs the run times of every task that runs, added up
unknownCount tasks that would run with no history; above 0, both times are too low
criticalPath the path wallMs measures, first task first

affected.kind says why the task is in the run:

  • input: a changed file is one of its inputs.
  • project: a file in its project changed, and it reads the whole project.
  • workspace: a workspace-wide file changed, such as .vx/workspace.ts.
  • package: a package it depends on through ^ changed; project names it.
  • named: you asked for it as project#task.
  • selected: another filter picked its project.

via lists the dependsOn path, nearest first, from the task to the one the change reached.

  • hit-local: cache hit on this machine.
  • hit-remote: cache hit in the remote cache.
  • miss: no entry for its key, so it runs.
  • no-cache: the task has no cache: true, so it runs.
  • group: a task with no command; it runs nothing itself.
  • not-started: a dev server every task after it restores from the cache, so it never starts.
  • skipped: it needs another platform, or waits on a task that does.

The explorer draws the first two green, the next two cyan, the rest grey.

It reads id, deps, cacheStatus and predicted.criticalPath, and ignores the rest. A task on the critical path is marked longest path.

The picture holds the picked task, everything it waits on and everything that waits on it. Over 40 tasks, it shows only the lists.

  • Not JSON. Paste the whole output of vx run <task> --all --dry --format json.
  • That is a vx error, not a plan. The command failed. Run it again and fix what it prints.
  • No "tasks" list. The JSON is not a plan. Run the command above.
  • A task without "id" or "deps". The plan was cut or edited. Write it again.
  • No task matches "…" No task id holds every word you typed.
NextCaching →

The green boxes come from the cache. See how vx decides what it can skip.

Turborepo, Nx and other product names are trademarks of their owners. vx is not affiliated with or endorsed by them.