Skip to content

Commit 9822e57

Browse files
committed
client: fix panic in automation loop if bridge stopped
1 parent 8b32761 commit 9822e57

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/connector/client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package connector
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"sync"
78

@@ -37,18 +38,20 @@ func (dc *DummyClient) Connect(ctx context.Context) {
3738

3839
dc.wg.Add(1)
3940
go func() {
41+
defer dc.wg.Done()
4042
log.Info().Int("portals", dc.Connector.Config.Automation.Portals.Count).Msg("Generating portals after login")
4143
for range dc.Connector.Config.Automation.Portals.Count {
4244
if _, err := generatePortal(
4345
ctx,
4446
dc.Connector.br,
4547
dc.UserLogin,
4648
dc.Connector.Config.Automation.Portals.Members,
47-
); err != nil {
49+
); errors.Is(err, context.Canceled) {
50+
return
51+
} else if err != nil {
4852
panic(err)
4953
}
5054
}
51-
dc.wg.Done()
5255
}()
5356
}
5457

0 commit comments

Comments
 (0)