Skip to content

Commit c983b2f

Browse files
author
Niels Möller
committed
Add workaround to explicitly close bastion connection on cancel.
1 parent 2c9ec33 commit c983b2f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cmd/litewitness/litewitness.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ func connectToBastion(ctx context.Context, bastion string, signer *signer, srv *
380380
slog.Info("connecting to bastion failed", "bastion", bastion, "err", err)
381381
return fmt.Errorf("connecting to bastion: %v", err)
382382
}
383+
// Ensure that the connection is closed when our context is cancelled.
384+
go func() {
385+
<-ctx.Done()
386+
conn.Close()
387+
}()
388+
383389
slog.Info("connected to bastion", "bastion", bastion)
384390
if logSpecific {
385391
ctx = witness.ContextWithBastion(ctx, bastion)

0 commit comments

Comments
 (0)