Skip to content

Commit 8aecdb8

Browse files
committed
handle panic in background workers
1 parent f380b4f commit 8aecdb8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hitless/handoff_worker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ func (hwm *handoffWorkerManager) ensureWorkerAvailable() {
117117
// onDemandWorker processes handoff requests and exits when idle
118118
func (hwm *handoffWorkerManager) onDemandWorker() {
119119
defer func() {
120+
// Handle panics to ensure proper cleanup
121+
if r := recover(); r != nil {
122+
internal.Logger.Printf(context.Background(),
123+
"hitless: worker panic recovered: %v", r)
124+
}
125+
120126
// Decrement active worker count when exiting
121127
hwm.activeWorkers.Add(-1)
122128
hwm.workerWg.Done()

0 commit comments

Comments
 (0)