Skip to content

Commit

Permalink
Close server more gracefully (#67)
Browse files Browse the repository at this point in the history
Let's wait a while for the complete redirection.
  • Loading branch information
b4k3r authored Jun 1, 2022
1 parent 7995b3b commit 0beade5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/cmd/profile/login_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package profile

import (
"bufio"
"context"
"encoding/base64"
"fmt"
"log"
Expand Down Expand Up @@ -234,13 +235,14 @@ func loginUsingWebBrowser(creds *session.StoredCredentials) error {

select {
case <-done:
server.Close()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

return errors.Wrap(server.Shutdown(shutdownCtx), "could not stop the server")
case <-time.After(2 * time.Minute):
server.Close()
return errors.New("login timeout exceeded")
}

return nil
}

func buildBrowserURL(endpoint, pubKey string) (string, error) {
Expand Down

0 comments on commit 0beade5

Please sign in to comment.