fix(healthcheck): prevent race condition on the healthchecker (#3400)

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>

Thanks also to @arturhoo for also trying to resolve this issue in #3410
This commit is contained in:
Matt Van Horn
2026-07-28 19:22:20 -07:00
committed by Quentin McGaw
parent cccd7c4c1b
commit c0073c9567
3 changed files with 18 additions and 8 deletions
+7
View File
@@ -43,6 +43,7 @@ type Loop struct {
start <-chan struct{}
running chan<- models.LoopStatus
userTrigger bool
healthDone <-chan struct{}
// Internal constant values
backoffTime time.Duration
}
@@ -68,6 +69,11 @@ func NewLoop(vpnSettings settings.VPN, ipv6Supported bool, vpnInputPorts []uint1
statusManager := loopstate.New(constants.Stopped, start, running, stop, stopped)
state := state.New(statusManager, vpnSettings)
// Initialize healthDone channel to a closed channel so that the first time
// we call <-l.healthDone it does not block
healthDone := make(chan struct{})
close(healthDone)
return &Loop{
statusManager: statusManager,
state: state,
@@ -95,6 +101,7 @@ func NewLoop(vpnSettings settings.VPN, ipv6Supported bool, vpnInputPorts []uint1
stop: stop,
stopped: stopped,
userTrigger: true,
healthDone: healthDone,
backoffTime: defaultBackoffTime,
}
}