fix(agent): add ok check for LoadAndDelete type assertion

sync.Map.LoadAndDelete returns any; unprotected type assertion could panic if an unexpected type were stored. Add ok check to safely handle mismatched types.
This commit is contained in:
程智超0668000959
2026-06-05 10:12:14 +08:00
parent 5224b9a4bc
commit f0f809db35
+4 -1
View File
@@ -88,7 +88,10 @@ func (al *AgentLoop) UnsubscribeEvents(id uint64) {
if !ok {
return
}
sub := value.(legacyEventSubscription)
sub, ok := value.(legacyEventSubscription)
if !ok {
return
}
sub.cancel()
if sub.sub != nil {
_ = sub.sub.Close()