Skip to content

Commit

Permalink
feat: add spinner when tailscale takes longer than ususal (#1140)
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Brecic <[email protected]>
  • Loading branch information
lbrecic authored Sep 27, 2024
1 parent 8d84ce0 commit 57a4bb5
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions pkg/cmd/workspace/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,34 @@ func waitForDial(workspace *apiclient.Workspace, activeProfile *config.Profile,
}
}

for {
dialConn, err := tsConn.Dial(context.Background(), "tcp", fmt.Sprintf("%s:%d", project.GetProjectHostname(workspace.Id, workspace.Projects[0].Name), ssh_config.SSH_PORT))
if err == nil {
return dialConn.Close()
connectChan := make(chan error)
spinner := time.After(3 * time.Second)
timeout := time.After(60 * time.Second)

go func() {
for {
dialConn, err := tsConn.Dial(context.Background(), "tcp", fmt.Sprintf("%s:%d", project.GetProjectHostname(workspace.Id, workspace.Projects[0].Name), ssh_config.SSH_PORT))
if err == nil {
connectChan <- dialConn.Close()
return
}
time.Sleep(time.Second)
}
}()

time.Sleep(time.Second)
select {
case err := <-connectChan:
return err
case <-spinner:
err := views_util.WithInlineSpinner("Connection to tailscale is taking longer than usual", func() error {
select {
case err := <-connectChan:
return err
case <-timeout:
return errors.New("secure connection to the Daytona Server could not be established. Please check your internet connection or Tailscale availability")
}
})
return err
}
}

Expand Down

0 comments on commit 57a4bb5

Please sign in to comment.