Skip to content
Merged
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
53 changes: 53 additions & 0 deletions e2e/tasks/test_task_failure_hang_depends
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail
# https://github.com/jdx/mise/discussions/6391

cat <<EOF >mise.toml
[tasks.clean]
run = 'echo "Cleaning..."'

[tasks.install]
wait_for = "clean"
run = "sleep 1"

[tasks.lint]
depends = "install"
run = "exit 1"

[tasks.test]
depends = "install"
run = "exit 1"

[tasks."build:docker"]
depends = "install"
run = "exit 1"

[tasks.check]
depends = ["lint", "test", "build:docker"]

[tasks."ci:check"]
depends = ["clean", "check"] # this variant currently hangs

# this variant now works after initial fix
# run = [
# { task = "clean" },
# { task = "check" }
# ]
EOF

# Test that task failure with dependencies does not hang
timeout 5s mise run --jobs 1 ci:check 2>&1 && exit_code=0 || exit_code=$?

# Check if it was a timeout (exit code 124)
if [ "$exit_code" -eq 124 ]; then
echo "FAIL: Task hung after dependency failure (timeout reached)"
exit 1
fi

# The command should fail with exit code 1
if [ "$exit_code" -ne 1 ]; then
echo "Expected exit code 1, got $exit_code"
exit 1
fi

echo "Test passed: task with failing dependency did not hang"
13 changes: 13 additions & 0 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,19 @@ impl Run {
}
}

// Check if we should stop early due to failure
if this.is_stopping() && !this.continue_on_error {
trace!("scheduler: stopping early due to failure, cleaning up main deps");
// Clean up the dependency graph to ensure the main_done signal is sent
let mut deps = main_deps.lock().await;
let tasks_to_remove: Vec<Task> = deps.all().cloned().collect();
for task in tasks_to_remove {
deps.remove(&task);
}
drop(deps);
break;
}

// Exit if main deps finished and nothing is running/queued
if *main_done_rx.borrow()
&& in_flight.load(std::sync::atomic::Ordering::SeqCst) == 0
Expand Down
Loading