WangzJi commented on code in PR #3023:
URL: https://github.com/apache/dubbo-go/pull/3023#discussion_r2347781653


##########
registry/nacos/service_discovery.go:
##########
@@ -86,6 +86,23 @@ func (n *nacosServiceDiscovery) Destroy() error {
                        logger.Errorf("Unregister nacos instance:%+v, err:%+v", 
inst, err)
                }
        }
+
+       // Clean up listeners to prevent potential leaks
+       n.listenerLock.Lock()
+       // Unsubscribe from all services to stop callbacks
+       for serviceName := range n.instanceListenerMap {
+               err := n.namingClient.Client().Unsubscribe(&vo.SubscribeParam{
+                       ServiceName: serviceName,
+                       GroupName:   n.group,
+               })
+               if err != nil {
+                       logger.Warnf("Failed to unsubscribe from service %s: 
%v", serviceName, err)
+               }
+       }
+       // Clear the listener map
+       n.instanceListenerMap = make(map[string]*gxset.HashSet)
+       n.listenerLock.Unlock()

Review Comment:
   @LQyt2012 PTAL.
   Thanks for the suggestion! I’ve updated the code in 
[b3d0846](https://github.com/apache/dubbo-go/pull/3023/commits/b3d08468a4a8e70a3d62be1e9f8efd65098414e4).
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to