watch
Re-run tasks in your repository, based on code changes.
turbo watch
is dependency-aware, meaning tasks will re-run in the order configured in turbo.json
.
Using turbo watch
with persistent tasks
Persistent tasks are marked with "persistent": true
, meaning they won't exit. Because of this, they cannot be depended on in your task graph.
This means that persistent tasks will be ignored when using turbo watch
, working the same way they do with turbo run
, allowing persistent and non-persistent tasks to be run at the same time.
Dependency-aware persistent tasks
When your script has a built-in watcher (like next dev
) capable of detecting changes in dependencies, you don't need to use turbo watch
. Instead, use your script's built-in watcher and mark the task as long-running using "persistent": true
.
Persistent tasks without dependency awareness
Some tools aren't monorepo-friendly, and do not hot-reload modules in dependencies. While you may be tempted to use turbo watch
with these tasks, they still won't be able to pick up on changes to dependencies.
Instead, you should make the task non-persistent and have turbo watch
restart the task when changes to dependencies are detected.
Limitations
Caching
All cache operations are disabled when executing tasks with turbo watch
.
Task outputs
If you have tasks that write to files checked into source control, there is a possibility that Watch Mode will run in an infinite loop. This is because Watch Mode watches your files for changes and will re-run tasks in packages that have changed. If a task creates a change, then that will trigger the task again.
Watch Mode has some logic to prevent this from happening using file hashes, but it isn't foolproof. To avoid this issue, we recommend removing any task outputs from git.
Was this helpful?