Dependencies and readiness
There are two dependency lists, and they are never the same list.
const api = defineService({
name: 'api',
provision: { image: { context: './services/api' } },
buildDependsOn: [protos.available, packages.available],
dependsOn: [db.available, migrate.available],
});buildDependsOn gates the image build. dependsOn gates the start, and gates nothing else — the build begins as soon as its own dependencies are satisfied, while Postgres is still coming up. Conflating the two costs you the entire build in cold-start latency, which is the number this tool competes on.
dependsOn waits until the dependency is usable, not until it has started. This is the single most important default in the configuration, and it is the reason wait-for-it.sh does not appear anywhere in an Alzo repository.
Restart when a dependency runs again
There is a third list, for when a dependency completing again makes this node stale rather than merely ordering it:
const worker = defineService({
name: 'worker',
run: 'pnpm worker',
dependsOn: [migrate.done], // ordering: start after
restartOn: [migrate.done], // invalidation: bounce when it runs again
});restartOn is declared on the node that becomes stale, not on the one that changed, because the consumer is what knows it has been invalidated. It is available on services, tasks and builds. Without it, a dependency restarting does not restart its dependents: its address stays the same, so there is usually nothing for a dependent to do.
Readiness
.available means usable now, and it resolves differently depending on what kind of node it is:
| Node | .available |
|---|---|
| Service | Readiness probe passed |
| Watch build | First successful emit — which you must declare |
| One-shot build | Exited 0 |
| Task | Exited 0 |
.available is what you almost always want, because it survives a node changing kind between profiles. The precise handles — .ready, .done, .started — exist for when you mean exactly those, and only on the kinds where they mean something: a service has no .done (a service that exits has crashed), and a task has no .ready (it has no probe). For a task, .done and .available are the same edge; prefer .done when the point is it finished.
This matters more than it looks. A build that is a turbo watch in development and a one-shot turbo run build in CI is the same node with the same handle; consumers write packages.available in both cases and get the correct semantics.
The editor narrows the handles of a build whose mode is known: a literal watch build exposes .ready, not .done; a literal or default one-shot build exposes .done, not .ready. A build whose mode is conditional keeps both precise handles, so prefer .available there.
A watch build has no default probe, and that is deliberate. turbo watch prints its version banner a moment after it starts and long before it has produced anything, so "it printed something" is not "it emitted" — and "the process is running" certainly is not. A mode: 'watch' build with no ready is a load error naming the node; write the line that means the artifact exists (ready: { log: /Watching for changes/ }), or ready: false if it really is usable the moment it launches, or mode: 'once' if it exits when the artifact is written.
A service with exactly one non-internal port defaults to a TCP probe; that proves a listener, not application or database readiness. It is why the README's opening example gives db a pg_isready probe: the API then waits for PostgreSQL to accept queries. For managed containers, Alzo probes from the instance network rather than trusting Docker Desktop's host proxy.
Probes
Six probe kinds:
ready: { inherit: 'image' } // the image's own HEALTHCHECK
ready: { tcp: { on: 'pg' } }
ready: { http: { path: '/ready', on: 'health' } }
ready: { exec: 'pg_isready -U postgres', in: 'container' }
ready: { log: /Watching for changes/ }
ready: { check: async (self) => (await pool.query('select 1 from users limit 1')).rowCount > 0,
period: '2s', failureThreshold: 60 }on is keyof ports, so a typo does not compile. For stock Redis, declare redis-cli ping: the official image has no HEALTHCHECK. A custom check can test application data when a listener alone is insufficient:
const cache = defineService({
name: 'cache',
ports: { redis: 6379 },
provision: { image: 'redis:8' },
volumes: { data: { path: '/data', onRemove: 'remove' } },
ready: { exec: 'redis-cli ping', in: 'container' },
});
const seeded = defineService({
name: 'seeded',
ports: { pg: 5432 },
provision: { image: 'postgres:17' },
env: { POSTGRES_PASSWORD: 'dev' },
ready: {
check: async (self) => (await pool.query('select 1 from users limit 1')).rowCount > 0,
period: '2s',
failureThreshold: 60,
},
});To use inherit, first supply an image with a healthcheck. For example, create redis/Dockerfile:
FROM redis:8
HEALTHCHECK --interval=2s --timeout=1s CMD redis-cli ping || exit 1const checkedCache = defineService({
name: 'checked-cache',
ports: { redis: 6379 },
provision: { image: { context: './redis' } },
ready: { inherit: 'image' },
});An image without a HEALTHCHECK refuses this policy at startup.
The check form is the one deliberate admission of control flow into the configuration, and it earns its place: a Postgres container binds its port within a second, but the schema is not applied and the seed data is not loaded for another twenty. A tcp probe passes immediately and every dependent starts against an empty database. The alternative to a typed callback is not no control flow — it is control flow smuggled in as a shell string.
Timing
Timing lives on the probe rather than on the edge, because it is a property of the check and not of whoever is waiting. All four fields are per attempt, and a node's budget is initialDelay + period × failureThreshold:
const slow = defineService({
name: 'slow',
ports: { http: 8080 },
provision: { image: 'acme/slow:dev' },
ready: {
http: { path: '/healthz', on: 'http' },
initialDelay: '10s',
period: '5s',
timeout: '3s',
failureThreshold: 3,
},
});That budget is 25 seconds, not three. timeout: '180s' is the natural misreading and means one attempt that hangs for three minutes — so timeout may not exceed period, and defaults to it, which is why most nodes never write it. To be more patient, raise period and failureThreshold.
The default startup path confirms an immediate first miss after 500ms, inside the first five-second period. That confirmation does not spend a failure slot, change the thirty-second default budget, or make steady-state health checks run more often. Writing an explicit cadence disables this adaptation.
A probe that exhausts its budget is a loud failure that names the node, and it never restarts anything; restart is opt-in. The budget for the whole graph is startupTimeout, in Profiles and settings.