@@ 58,7 58,8 @@ func WithTx(ctx context.Context, opts *sql.TxOptions, fn func(tx *sql.Tx) error)
txErr = tx.Commit()
}
- if errors.Is(err, context.Canceled) && errors.Is(txErr, sqldriver.ErrBadConn) {
+ if (errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)) &&
+ errors.Is(txErr, sqldriver.ErrBadConn) {
// When a query fails because the context has been canceled, pq will
// return "driver: bad connection" from tx.Rollback. Do not panic in
// this case. See https://github.com/lib/pq/issues/1137