Repository navigation
fix(audio): release the loading flag so a failed effect can retry - #13
Merged
Merged
Conversation
loadEffects set loading[key] and no path cleared it, so one failed XHR or decode left the effect permanently skipped. Every exit now settles the flag through a shared done callback, while it stays set for the duration of the request so parallel calls still cannot duplicate one.
KaykCaputo
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Audio effects could get permanently stuck after one failed load:
loadEffects()setloading[key] = truebut neither the XHR error/timeout/non-success paths nor the decode paths cleared it, so every laterunlock()skipped the effect (loading[key]guard) and no new request was ever sent (Fixes #4).Root cause
The flag had a set site but no settle site. The request lifecycle has four exits — network error, timeout, non-success status, decode failure — and success, and only the success exit was harmless (because the
buffers[key]guard short-circuits first).Fix
Every exit now runs one shared
settlecallback (passed asdecode'sdone) that deletesloading[key]. The flag stays set for the duration of the request, so parallel calls still skip an in-flight effect instead of duplicating it, and successful decodes keep caching the buffer.Testing
New
tests/audio.test.cjs(node --test, jsdom-free vm harness matching the repo's other.test.cjsfiles) drives the page's publicunlock()flow with a fake XHR and AudioContext: a network error is followed by a new request (fails on the old code), a decoded effect is cached and not re-requested, a decode failure leaves the effect retryable (fails on the old code), and parallel unlocks never duplicate an in-flight request. The fullnode --test tests/*.test.cjsshows the same 3 pre-existing Windows-environment failures on untouchedmasterand with this change; 12 pass either way.