Skip to content

Commit d187a54

Browse files
authored
fix(removeQueue): add panic recovery and double-check for outbound removal (#80)
* fix(removeQueue): add panic recovery and double-check for outbound removal * remove tag from pending if already removed
1 parent ebc276f commit d187a54

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

adapter/groups/manager.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,24 @@ func (rq *removalQueue) checkPending() {
306306
}
307307

308308
if len(toRemove) > 0 {
309+
defer func() {
310+
if err := recover(); err != nil {
311+
rq.logger.Error("panic during outbound/endpoint removal", "error", err)
312+
}
313+
}()
309314
rq.mu.Lock()
310315
defer rq.mu.Unlock()
311316
for _, tag := range toRemove {
312317
item, exists := rq.pending[tag]
313318
if !exists {
314319
continue
315320
}
321+
// double check if outbound/endpoint still exists
322+
if _, exists = rq.outMgr.Outbound(tag); !exists {
323+
rq.logger.Trace("outbound already removed", "tag", tag)
324+
delete(rq.pending, tag)
325+
continue
326+
}
316327
rq.logger.Debug("removing outbound", "tag", tag)
317328
if item.isEndpoint {
318329
rq.epMgr.Remove(tag)

0 commit comments

Comments
 (0)