04Run tasks
Explore the task graph
See which tasks wait on which, and why. Ask vx for the plan of a run: nothing runs.
vx run build test --all --dry --format json > plan.jsonHere 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.
Open your own plan
Read the picture
Section titled “Read the picture”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.
See the plan in your terminal
Section titled “See the plan in your terminal”Drop --format json and vx prints the same plan as a table:
vx run build test --all --dry 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 executionRead 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.
Open your own graph
Section titled “Open your own graph”-
Write your plan to a file, from your workspace root:
Terminal window vx run build --all --dry --format json > plan.json -
Under the picture, open Open your own plan and drop
plan.jsonin the box. Or paste it, then press Read plan. -
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.
Ask why one task waits on another
Section titled “Ask why one task waits on another”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:
@demo/web#test → @demo/ui#buildOne 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
Which tasks would run?
Section titled “Which tasks would run?”The plan is plain JSON, so jq answers questions the picture does not:
jq '[.tasks[] | select(.cacheStatus == "miss") | .id]' plan.json[ "@demo/admin#build", "@demo/ui#build", "@demo/web#build", "@demo/admin#test", "@demo/ui#test", "@demo/web#test"]What sets the run’s length?
Section titled “What sets the run’s length?”predicted.criticalPath is the longest path of tasks that run, by their usual times. wallMs is how long it takes:
jq '.predicted' plan.json{ "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.
Only part of the workspace
Section titled “Only part of the workspace”Any run selection gives a plan of the same shape. Explore it the same way:
vx run build --filter @demo/web... --dry --format json > plan.jsonvx 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 itsinputs.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;projectnames it.named: you asked for it asproject#task.selected: another filter picked its project.
via lists the dependsOn path, nearest first, from the task to the one the change reached.
What each status means
Section titled “What each status means”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 nocache: 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.
What the explorer reads
Section titled “What the explorer reads”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.
Messages
Section titled “Messages”Not JSON.Paste the whole output ofvx 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.