Skip to content

Commit 54055dc

Browse files
authored
fix(cli): prevent asynchronous print of version mismatch in config-ssh (#13845)
1 parent 407d263 commit 54055dc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cli/configssh.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ func (r *RootCmd) configSSH() *serpent.Command {
236236
r.InitClient(client),
237237
),
238238
Handler: func(inv *serpent.Invocation) error {
239+
ctx := inv.Context()
240+
239241
if sshConfigOpts.waitEnum != "auto" && skipProxyCommand {
240242
// The wait option is applied to the ProxyCommand. If the user
241243
// specifies skip-proxy-command, then wait cannot be applied.
@@ -244,7 +246,14 @@ func (r *RootCmd) configSSH() *serpent.Command {
244246
sshConfigOpts.header = r.header
245247
sshConfigOpts.headerCommand = r.headerCommand
246248

247-
recvWorkspaceConfigs := sshPrepareWorkspaceConfigs(inv.Context(), client)
249+
// Talk to the API early to prevent the version mismatch
250+
// warning from being printed in the middle of a prompt.
251+
// This is needed because the asynchronous requests issued
252+
// by sshPrepareWorkspaceConfigs may otherwise trigger the
253+
// warning at any time.
254+
_, _ = client.BuildInfo(ctx)
255+
256+
recvWorkspaceConfigs := sshPrepareWorkspaceConfigs(ctx, client)
248257

249258
out := inv.Stdout
250259
if dryRun {
@@ -366,7 +375,7 @@ func (r *RootCmd) configSSH() *serpent.Command {
366375
return xerrors.Errorf("fetch workspace configs failed: %w", err)
367376
}
368377

369-
coderdConfig, err := client.SSHConfiguration(inv.Context())
378+
coderdConfig, err := client.SSHConfiguration(ctx)
370379
if err != nil {
371380
// If the error is 404, this deployment does not support
372381
// this endpoint yet. Do not error, just assume defaults.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy