safeSweepIdleStreams runs sweepIdleStreams under a panic recovery so an unexpected panic in the sweep cannot kill the janitor goroutine and silently reintroduce the very leak it exists to prevent. The next tick retries.
(ctx context.Context)
| 4767 | // goroutine and silently reintroduce the very leak it exists to |
| 4768 | // prevent. The next tick retries. |
| 4769 | func (p *Server) safeSweepIdleStreams(ctx context.Context) { |
| 4770 | defer func() { |
| 4771 | if r := recover(); r != nil { |
| 4772 | p.logger.Error(ctx, "stream janitor sweep panicked, will retry next tick", |
| 4773 | slog.F("panic", r)) |
| 4774 | } |
| 4775 | }() |
| 4776 | p.sweepIdleStreams() |
| 4777 | } |
| 4778 | |
| 4779 | // sweepIdleStreams iterates chatStreams once and delegates each entry |
| 4780 | // to cleanupStreamIfIdle. Range may skip entries that become reapable |