Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

- **Fixed** After Ctrl+C, a task exiting with a non-zero code (like 130) no longer makes `vp run` kill the other tasks while they're still shutting down ([#1024](https://github.com/voidzero-dev/vite-task/pull/1024)).
- **Changed** When automatic file-access tracking cannot record everything a task did, the "Not cached" summary line now includes the specific reason (for example, that the tracking channel ran out of capacity or that installing the seccomp filter failed for a given executable) ([#1054](https://github.com/voidzero-dev/vite-task/pull/1054), [#1056](https://github.com/voidzero-dev/vite-task/pull/1056)).
- **Changed** Invalid remote cache endpoint URLs in `cache.remote.url` or `VP_REMOTE_CACHE_URL` (such as missing schemes, non-`http`/`https` schemes, or missing hosts) now fail upfront during configuration and planning instead of warning per task during execution, and `vp run --help` now documents `VP_REMOTE_CACHE`, `VP_REMOTE_CACHE_URL`, and `VP_REMOTE_CACHE_HEADER_<NAME>` ([#1048](https://github.com/voidzero-dev/vite-task/pull/1048)).
- **Changed** Removed `NEXT_*`, `VERCEL`, `VERCEL_*`, `USE_OUTPUT_FOR_EDGE_FUNCTIONS`, `NOW_BUILDER`, `VC_MICROFRONTENDS_CONFIG_FILE_NAME`, `GITHUB_*`, `ACTIONS_ID_TOKEN_REQUEST_URL`, `DOCKER_*`, `BUILDKIT_*`, `COMPOSE_*`, and `*_TOKEN` from the default untracked environment variables passed to cached tasks. Tasks that need any of these variables should declare them explicitly in `cache.env` or `cache.untrackedEnv` ([#1044](https://github.com/voidzero-dev/vite-task/pull/1044)).
Expand Down
2 changes: 1 addition & 1 deletion crates/vt/src/session/execute/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl ExecutionContext<'_> {
}
};
tracing::debug!(failed, elapsed = ?start.elapsed(), "finished the task item");
if failed {
if failed && !self.cancel_token.is_cancelled() {
self.fast_fail_token.cancel();
}
}
Expand Down
11 changes: 9 additions & 2 deletions crates/vt_bin/src/vtt/exit_on_ctrlc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use std::sync::Arc;
///
/// Sets up a Ctrl+C handler, emits a "ready" milestone, then waits.
/// When Ctrl+C is received, prints "ctrl-c received" and exits.
pub fn run() -> Result<(), Box<dyn std::error::Error>> {
pub fn run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
let cleanup_ms: u64 = args.first().map(|s| s.parse()).transpose()?.unwrap_or(0);
let exit_code: i32 = args.get(1).map(|s| s.parse()).transpose()?.unwrap_or(0);

// On Windows, an ancestor process (e.g. cargo, the test harness) may have
// been created with CREATE_NEW_PROCESS_GROUP, which implicitly calls
// SetConsoleCtrlHandler(NULL, TRUE) and sets CONSOLE_IGNORE_CTRL_C in the
Expand Down Expand Up @@ -40,5 +43,9 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {

ctrlc_once_lock.wait();
println!("ctrl-c received");
Ok(())
if cleanup_ms > 0 {
std::thread::sleep(std::time::Duration::from_millis(cleanup_ms));
println!("cleanup done");
}
std::process::exit(exit_code);
}
2 changes: 1 addition & 1 deletion crates/vt_bin/src/vtt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn main() {
}
"cp" => cp::run(&args[2..]),
"exit" => exit::run(&args[2..]),
"exit-on-ctrlc" => exit_on_ctrlc::run(),
"exit-on-ctrlc" => exit_on_ctrlc::run(&args[2..]),
"fs" => fs::run(&args[2..]),
"grep-file" => {
grep_file::run(&args[2..]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "ctrl-c-parallel-cleanup-test",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@ctrl-c-parallel-cleanup/a",
"scripts": {
"dev": "vtt exit-on-ctrlc 0 130"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@ctrl-c-parallel-cleanup/b",
"scripts": {
"dev": "vtt exit-on-ctrlc 1000"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- packages/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[[e2e]]
name = "ctrl_c_lets_parallel_tasks_finish_cleanup"
comment = """
Ctrl+C with two parallel tasks: a exits 130 immediately, b takes a second to clean up. b shouldn't get killed when a exits.
"""
steps = [
{ argv = [
"vt",
"run",
"-r",
"--parallel",
"--no-cache",
"dev",
], interactions = [
{ "expect-milestone" = "ready" },
{ "expect-milestone" = "ready" },
{ "write-key" = "ctrl-c" },
] },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ctrl_c_lets_parallel_tasks_finish_cleanup

Ctrl+C with two parallel tasks: a exits 130 immediately, b takes a second to clean up. b shouldn't get killed when a exits.

## `vt run -r --parallel --no-cache dev`

**Exit code:** 130

**→ expect-milestone:** `ready`

```
~/packages/a$ vtt exit-on-ctrlc 0 130 ⊘ cache disabled
~/packages/b$ vtt exit-on-ctrlc 1000 ⊘ cache disabled
```

**→ expect-milestone:** `ready`

```
~/packages/a$ vtt exit-on-ctrlc 0 130 ⊘ cache disabled
~/packages/b$ vtt exit-on-ctrlc 1000 ⊘ cache disabled
```

**← write-key:** `ctrl-c`

```
~/packages/a$ vtt exit-on-ctrlc 0 130 ⊘ cache disabled
~/packages/b$ vtt exit-on-ctrlc 1000 ⊘ cache disabled
ctrl-c received
ctrl-c received

cleanup done

---
vt run: 1/2 successful. (Run `vt run --last-details` for full details)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "cache": true }
1 change: 1 addition & 0 deletions docs/cancellation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ When the user presses Ctrl-C:
1. The OS delivers SIGINT (Unix) or CTRL_C_EVENT (Windows) directly to all processes in the terminal's foreground process group — both the runner and child tasks. This is standard OS behavior, not something `vp run` implements.
2. No new tasks are scheduled after the signal.
3. Results of in-flight tasks are **not cached**, even if a task handles the signal gracefully and exits 0. The output may be incomplete, so caching it would risk false cache hits on subsequent runs.
4. Tasks that exit non zero after Ctrl+C don't trigger [fast-fail](#fast-fail), so other tasks can finish shutting down.

## Fast-fail

Expand Down