Skip to content

Commit ebb1446

Browse files
authored
Fix race condition reading from PTTY (#1906)
Execution of fast docker compose commands are getting stuck sometimes. One possible theory is that we are closing the pseudo-tty before the copy has finished, and it hangs there. Close the pseudo-TTY after waiting for the finalization of the goroutine, so we avoid problems caused by closing it while it is being read.
1 parent 24cc92b commit ebb1446

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/compose/compose_other.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ func (p *Project) runDockerComposeCmd(ctx context.Context, opts dockerComposeOpt
5555

5656
logger.Debugf("running command: %s", cmd)
5757
err = cmd.Run()
58-
ptty.Close()
5958
tty.Close()
6059
wg.Wait()
60+
61+
// Don't close the PTTY before the goroutine with the Copy has finished.
62+
ptty.Close()
63+
6164
if err != nil {
6265
if msg := cleanComposeError(errBuffer.String()); len(msg) > 0 {
6366
return fmt.Errorf("%w: %s", err, msg)

0 commit comments

Comments
 (0)