From 7f4f14b505fdff4a026b19cb27a37fc7d4bf4af1 Mon Sep 17 00:00:00 2001 From: henrygd Date: Tue, 31 Mar 2026 16:10:59 -0400 Subject: [PATCH] fix(agent,windows): raise timeout on first sensor collection to allow LHM to start --- agent/sensors.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/agent/sensors.go b/agent/sensors.go index e4c0e7c9..bb4a1de7 100644 --- a/agent/sensors.go +++ b/agent/sensors.go @@ -26,6 +26,7 @@ type SensorConfig struct { isBlacklist bool hasWildcards bool skipCollection bool + firstRun bool } func (a *Agent) newSensorConfig() *SensorConfig { @@ -52,6 +53,7 @@ func (a *Agent) newSensorConfigWithEnv(primarySensor, sysSensors, sensorsEnvVal context: context.Background(), primarySensor: primarySensor, skipCollection: skipCollection, + firstRun: true, sensors: make(map[string]struct{}), } @@ -167,6 +169,14 @@ func (a *Agent) getTempsWithTimeout(getTemps getTempsFn) ([]sensors.TemperatureS err error } + // Use a longer timeout on the first run to allow for initialization + // (e.g. Windows LHM subprocess startup) + timeout := temperatureFetchTimeout + if a.sensorConfig.firstRun { + a.sensorConfig.firstRun = false + timeout = 10 * time.Second + } + resultCh := make(chan result, 1) go func() { temps, err := a.getTempsWithPanicRecovery(getTemps) @@ -176,7 +186,7 @@ func (a *Agent) getTempsWithTimeout(getTemps getTempsFn) ([]sensors.TemperatureS select { case res := <-resultCh: return res.temps, res.err - case <-time.After(temperatureFetchTimeout): + case <-time.After(timeout): return nil, errTemperatureFetchTimeout } }