Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a76fd7d

Browse files
committed
fix(cli): prevent asynchronous print of version mismatch in config-ssh
1 parent 978364b commit a76fd7d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cli/configssh.go

Lines changed: 10 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,13 @@ 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 bad placement of the
250+
// version mismatch warning. The asynchronous requests
251+
// issued by sshPrepareWorkspaceConfigs may trigger the
252+
// warning at any time.
253+
_, _ = client.BuildInfo(ctx)
254+
255+
recvWorkspaceConfigs := sshPrepareWorkspaceConfigs(ctx, client)
248256

249257
out := inv.Stdout
250258
if dryRun {
@@ -366,7 +374,7 @@ func (r *RootCmd) configSSH() *serpent.Command {
366374
return xerrors.Errorf("fetch workspace configs failed: %w", err)
367375
}
368376

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

0 commit comments

Comments
 (0)