From 2dd604192fbeb788b01ae30f46e8b831ec76e52a Mon Sep 17 00:00:00 2001 From: SlavaVlad Date: Mon, 15 Jun 2026 01:36:24 +0300 Subject: [PATCH] fix: TypeScript - capture Howl ref in closure --- lib/sounds.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sounds.ts b/lib/sounds.ts index c449d43..14cde51 100644 --- a/lib/sounds.ts +++ b/lib/sounds.ts @@ -121,7 +121,7 @@ const howlCache = new Map(); export function playSoundUrl(url: string) { let h = howlCache.get(url); if (!h) { - h = new Howl({ + const newH = new Howl({ src: [url], format: url.endsWith(".mp3") ? ["mp3"] : url.endsWith(".ogg") ? ["ogg"] : ["mp3", "ogg"], volume: 0.4, @@ -130,10 +130,11 @@ export function playSoundUrl(url: string) { }, onplayerror: (_id: number, err: unknown) => { console.error("[BaraBingo] Howl play error:", url, err); - h.once("unlock", () => h.play()); + newH.once("unlock", () => newH.play()); }, }); - howlCache.set(url, h); + howlCache.set(url, newH); + h = newH; } h.play(); }