From 508b09327806b83a5dff448ea7cb55d9ed86deaa Mon Sep 17 00:00:00 2001 From: yusing Date: Tue, 11 Feb 2025 07:12:08 +0800 Subject: [PATCH] fix health monitor panic --- internal/watcher/health/monitor/monitor.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/watcher/health/monitor/monitor.go b/internal/watcher/health/monitor/monitor.go index 32a2fd0..b27dd43 100644 --- a/internal/watcher/health/monitor/monitor.go +++ b/internal/watcher/health/monitor/monitor.go @@ -164,6 +164,12 @@ func (mon *monitor) String() string { // MarshalJSON implements json.Marshaler of HealthMonitor. func (mon *monitor) MarshalJSON() ([]byte, error) { res := mon.lastResult + if res == nil { + res = &health.HealthCheckResult{ + Healthy: true, + } + } + return (&JSONRepresentation{ Name: mon.service, Config: mon.config,