Skip to content

Commit f532405

Browse files
committed
prevent panics when context doesn't have expected value
1 parent 6ce29e6 commit f532405

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/pool/pool.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ func (p *ConnPool) waitTurn(ctx context.Context) error {
317317
start := time.Now()
318318
defer func() {
319319
if c, found := ctx.Value("connectionQueueTimes").(chan<- time.Duration); found {
320-
c <- time.Since(start)
320+
select {
321+
case c <- time.Since(start):
322+
default: // prevent a full buffer from freezing the application
323+
}
321324
}
322325
}()
323326

0 commit comments

Comments
 (0)