Skip to content

Commit 6ce29e6

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

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/pool/pool.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ func (p *ConnPool) waitTurn(ctx context.Context) error {
316316

317317
start := time.Now()
318318
defer func() {
319-
ctx.Value("connectionQueueTimes").(chan<- time.Duration) <- time.Since(start)
319+
if c, found := ctx.Value("connectionQueueTimes").(chan<- time.Duration); found {
320+
c <- time.Since(start)
321+
}
320322
}()
321323

322324
select {

0 commit comments

Comments
 (0)