Skip to content

Commit e6a7d88

Browse files
firecowclaude
andcommitted
Fix wait command to always check replica count
Previously, the wait command would trust UpdateStatus.State when present without verifying that all replicas were actually running. This could cause the command to exit successfully even when some tasks were still starting or had failed. Now we always check that running tasks match total tasks before considering a service as done, matching the behavior of docker-stack-wait. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d782389 commit e6a7d88

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/commands/wait-cmd.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ export async function handler (args: ArgumentsCamelCase) {
4444
tasks = await dockerode.listTasks({filters: {"label": [`com.docker.stack.namespace=${appName}`], "desired-state": ["running"]}}) as Task[];
4545

4646
for (const s of services) {
47-
if (s.UpdateStatus?.State) {
47+
const runningTasks = tasks.filter((t) => t.Status.State === "running" && t.ServiceID === s.ID);
48+
const totalTasks = tasks.filter((t) => t.ServiceID === s.ID);
49+
50+
// Always check replica count first
51+
if (totalTasks.length > runningTasks.length) {
52+
serviceStateMap.set(s.ID, "replicating");
53+
} else if (s.UpdateStatus?.State && !["completed", "rollback_completed"].includes(s.UpdateStatus.State)) {
4854
serviceStateMap.set(s.ID, s.UpdateStatus.State);
49-
} else {
50-
const runningTasks = tasks.filter((t) => t.Status.State === "running" && t.ServiceID === s.ID);
51-
const totalTasks = tasks.filter((t) => t.ServiceID === s.ID);
52-
if (totalTasks.length > runningTasks.length) {
53-
serviceStateMap.set(s.ID, "replicating");
54-
}
5555
}
5656
}
5757

0 commit comments

Comments
 (0)