Watch doesn't exit when persistent task fails
Verify canary release
- [x] I verified that the issue exists in the latest Turborepo canary release.
Link to code that reproduces this issue
https://github.com/OliverJAsh/turbo-watch-persistent-exit
Which canary version will you have in your reproduction?
2.4.5-canary.2
Environment information
CLI:
Version: 2.4.5-canary.2
Path to executable: /Users/oliver/Code/reduced-test-cases/turbo-watch-persistent-exit/node_modules/.pnpm/[email protected]/node_modules/turbo-darwin-arm64/bin/turbo
Daemon status: Running
Package manager: pnpm9
Platform:
Architecture: aarch64
Operating system: macos
WSL: false
Available memory (MB): 5567
Available CPU cores: 10
Environment:
CI: None
Terminal (TERM): xterm-256color
Terminal program (TERM_PROGRAM): iTerm.app
Terminal program version (TERM_PROGRAM_VERSION): 3.5.11
Shell (SHELL): /run/current-system/sw/bin/fish
stdin: false
Expected behavior
When watching a persistent task, if the task exits with a non-zero exit code, watch should also exit (like run does).
Actual behavior
watch does not exit.
To Reproduce
package.json:
{
"packageManager": "[email protected]",
"scripts": {
"server": "exit 1"
},
"dependencies": {
"turbo": "2.4.5-canary.2"
}
}
turbo.json:
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"server": {
"persistent": true
}
}
}
Then run:
$ pnpm exec turbo watch server
Additional context
No response
Edit: This comment makes no sense, ignore it.
I'm not sure exiting is desirable in this case. If you have a linter for example running in watch mode it makes sense that it'll fail during the course of development, but that shouldn't bring everything else down.
In our repo @OliverJAsh an example of this'd be app#gen-js, which can fail if you save with broken JSON syntax. In this sense turbo watch is kind of self-healing.
If I understand correctly, when a persistent task exits, it will never run again, even if inputs change for example. So in this case I'm not sure it is self-healing.
In our repo @OliverJAsh an example of this'd be
app#gen-js, which can fail if you save with broken JSON syntax. In this senseturbo watchis kind of self-healing.
I might be misunderstanding but our app#gen-js is not persistent.
If you have a linter for example running in watch mode it makes sense that it'll fail during the course of development, but that shouldn't bring everything else down.
Assuming you mean using the linter's built-in watch mode, in which case a non-zero exit would indicate something more severe than a lint error. Lint errors alone wouldn't cause the linter's watch mode to exit.
(Otherwise, if it's not using the linter's built-in watch mode, it wouldn't be configured as a persistent task.)
I completely glazed over the word "persistent". 🤦