diff --git a/common/src/util/lazy-response-ads.ts b/common/src/util/lazy-response-ads.ts index 1b491a44d8..2b263c9d5f 100644 --- a/common/src/util/lazy-response-ads.ts +++ b/common/src/util/lazy-response-ads.ts @@ -29,7 +29,8 @@ export function getResponseAdForSlot( slotIndex: number, ): T | undefined { if (ads.length === 0) return undefined - return ads[Math.max(0, Math.floor(slotIndex)) % ads.length] + const safeSlotIndex = Number.isFinite(slotIndex) ? slotIndex : 0 + return ads[Math.max(0, Math.floor(safeSlotIndex)) % ads.length] } export function createLazyResponseAdQueue<