From 12a9d6336ba69ce93d9b0b0f903d0c0fbc3b0a3c Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Fri, 15 Nov 2024 14:48:17 +0000 Subject: [PATCH] fix(agent): start rpty lifecycle after all reads/writes (#15535) Fixes https://github.com/coder/internal/issues/214 #15475 missed that we also write to `rpty` after starting `rpty.lifecycle()`. This PR moves the function call right at the end. Hopefully this should address the data races before we go resorting to mutexes. --- agent/reconnectingpty/screen.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/reconnectingpty/screen.go b/agent/reconnectingpty/screen.go index 3fc93d8810..ca3451fe33 100644 --- a/agent/reconnectingpty/screen.go +++ b/agent/reconnectingpty/screen.go @@ -78,8 +78,6 @@ func newScreen(ctx context.Context, cmd *pty.Cmd, options *Options, logger slog. } rpty.id = hex.EncodeToString(buf) - go rpty.lifecycle(ctx, logger) - settings := []string{ // Disable the startup message that appears for five seconds. "startup_message off", @@ -124,6 +122,8 @@ func newScreen(ctx context.Context, cmd *pty.Cmd, options *Options, logger slog. return rpty } + go rpty.lifecycle(ctx, logger) + return rpty }