Skip to content

Commit

Permalink
Add comment explaining error handling in removeGateway
Browse files Browse the repository at this point in the history
Edoardo asked about it some time ago. I forgot to add the explanation to
the code.

#14135 (comment)
  • Loading branch information
ravicious authored and github-actions committed Jul 19, 2022
1 parent 78d45cd commit 8b72cfa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/teleterm/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ func (s *Service) RemoveGateway(gatewayURI string) error {

// removeGateway assumes that mu is already held by a public method.
func (s *Service) removeGateway(gateway *gateway.Gateway) error {
// In case closing the gateway fails, we want to return early and leave the gateway in the map.
//
// This way the gateway will remain shown as available in the app. The user will see the error
// related to closing the gateway and will be able to attempt to close it again.
//
// This is preferable to removing the gateway from the hash map. Since Connect remembers the port
// used for a particular db server + username pair, the user would be able to reopen the same
// gateway on the occupied port only to see an error.
if err := gateway.Close(); err != nil {
return trace.Wrap(err)
}
Expand Down

0 comments on commit 8b72cfa

Please sign in to comment.