Skip to content

Close the ttyWriter done channel after context cancel - #14115

Closed
Hashim1999164 wants to merge 1 commit into
docker:mainfrom
Hashim1999164:fix/tty-done-after-context-cancel
Closed

Close the ttyWriter done channel after context cancel#14115
Hashim1999164 wants to merge 1 commit into
docker:mainfrom
Hashim1999164:fix/tty-done-after-context-cancel

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Fixes #14114

ttyWriter.Done sent on an unbuffered channel. After SIGTERM the render goroutine exits through ctx.Done() and never receives, so Done blocked forever. Closing the channel returns immediately even when that goroutine is already gone.

Test plan

  • go test ./cmd/display/
  • TestDoneAfterContextCancelDoesNotHang covers cancel then Done

Signed-off-by: Hashim1999164 <64767361+Hashim1999164@users.noreply.github.com>
@glours

glours commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Thanks for opening this — the underlying bug (ttyWriter.Done hanging forever after the command context is cancelled) is real, and we're addressing it. This particular fix isn't safe to merge though.

close(w.done) never blocks, which does fix the reported hang, but it panics with close of closed channel the moment the shared ttyWriter bus goes through more than one Start/Done cycle in the same process, and that already happens

today:

  • docker compose run nests a create/start cycle inside its own run cycle (startDependencies calling the public Create/Start).
  • docker compose publish nests a push cycle inside its own publish cycle.
  • docker compose rm --stop runs a stop cycle sequentially, then its own remove cycle.

We reproduced the panic against this PR's diff on all three paths. A correct fix needs to avoid opening a second bracket on the shared bus in the first place (the unexported methods should be called directly there, as up/scale already do), and make the channel itself safe to close more than once for the paths that legitimately run sequential cycles.
#14119 fixes this properly, closing in favor of that one.

Separately: this account's recent activity, near-simultaneous, template-identical PRs opened across dozens of unrelated, high-profile repositories over the last few days, matches the pattern of low-effort, automated AI-generated contribution farming. We don't accept that kind of submission on docker/compose.

@glours glours closed this Aug 24, 2026
@Hashim1999164

Copy link
Copy Markdown
Author

Okay @glours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ttyWriter.Done still hangs forever when the context was canceled before Done runs

2 participants