Skip to content

Commit d84d792

Browse files
committed
fix: Close coordinator on context cancellation
1 parent 4183c5e commit d84d792

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

agent/agent.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ func (a *agent) runCoordinator(ctx context.Context) {
288288
a.logger.Warn(context.Background(), "failed to dial", slog.Error(err))
289289
continue
290290
}
291+
//nolint:revive // Defer is ok because we're exiting this loop.
292+
defer coordinator.Close()
291293
a.logger.Info(context.Background(), "connected to coordination server")
292294
break
293295
}
@@ -296,7 +298,6 @@ func (a *agent) runCoordinator(ctx context.Context) {
296298
return
297299
default:
298300
}
299-
defer coordinator.Close()
300301
sendNodes, errChan := tailnet.ServeCoordinator(coordinator, a.network.UpdateNodes)
301302
a.network.SetNodeCallback(sendNodes)
302303
select {

0 commit comments

Comments
 (0)