From 864cfbb37584d55e8818baced6c18230b0e508a8 Mon Sep 17 00:00:00 2001 From: UUBulb <35923940+uubulb@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:27:30 +0800 Subject: [PATCH] fix: add nil check for ReportSystemState (#583) --- service/rpc/nezha.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/rpc/nezha.go b/service/rpc/nezha.go index 5c98fcb..672529b 100644 --- a/service/rpc/nezha.go +++ b/service/rpc/nezha.go @@ -103,6 +103,12 @@ func (s *NezhaHandler) ReportSystemState(stream pb.NezhaService_ReportSystemStat state := model.PB2State(state) singleton.ServerLock.RLock() + + if singleton.ServerList[clientID] == nil { + singleton.ServerLock.RUnlock() + return nil + } + singleton.ServerList[clientID].LastActive = time.Now() singleton.ServerList[clientID].State = &state // 应对 dashboard 重启的情况,如果从未记录过,先打点,等到小时时间点时入库