mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
fix: catch missing output with reconnecting PTY (#9094)
I forgot that waiting on the cond releases the lock so it was possible to get pty output after writing the buffer but before adding the pty to the map. To fix, add the pty to the map while under the same lock where we read from the buffer. The rest does not need to be behind the lock so I moved it out of doAttach, and that also means we no longer need waitForStateOrContextLocked. Also, this can hit a logger error saying the attach failed which fails the tests however it is not that the attach failed, just that the process already ran and exited, so when the process exits do not set an error, instead for now assume this is an expected close.
This commit is contained in:
@ -1134,7 +1134,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
|
||||
rpty.Wait()
|
||||
a.reconnectingPTYs.Delete(msg.ID)
|
||||
}); err != nil {
|
||||
rpty.Close(err.Error())
|
||||
rpty.Close(err)
|
||||
return xerrors.Errorf("start routine: %w", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user