mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(agent/reconnectingpty): generate rpty id before starting lifecycle (#15475)
Fixes https://github.com/coder/coder/issues/12687 There was a race condition where we would start the rpty lifecycle before generating the ID, leading to a data race where we would try to concurrently read and write the struct field.
This commit is contained in:
@@ -67,8 +67,6 @@ func newScreen(ctx context.Context, cmd *pty.Cmd, options *Options, logger slog.
|
||||
timeout: options.Timeout,
|
||||
}
|
||||
|
||||
go rpty.lifecycle(ctx, logger)
|
||||
|
||||
// Socket paths are limited to around 100 characters on Linux and macOS which
|
||||
// depending on the temporary directory can be a problem. To give more leeway
|
||||
// use a short ID.
|
||||
@@ -80,6 +78,8 @@ 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",
|
||||
|
||||
Reference in New Issue
Block a user