fix(core): retry bpm-detective import after transient failure#2736
fix(core): retry bpm-detective import after transient failure#2736santhiprakash wants to merge 1 commit into
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Approved on James's go. Verified the bug + fix:
The cached-promise-never-reset bug is real — on a transient import("bpm-detective") failure the old code's .catch(() => null) left bpmDetectivePromise as a resolved-to-null promise that was never cleared, so if (!bpmDetectivePromise) stayed false and every later analyzeMusicFromBuffer silently skipped BPM detection for the rest of the session (breaking music-reactive animations / beat guides with no error).
The fix resets bpmDetectivePromise = null in the failure handler so the next call retries the import, caches only the default production import (custom loaders bypass the cache → unit-testable), and correctly distinguishes a transient import failure (reset + retry) from a successful-but-empty module (cached null, since retrying wouldn't help). Tests cover the retry-after-transient-failure path plus the default-export / module-object fallbacks. CI green.
— Rames
|
Thanks for this — the fix looks good and CI is green, so it's approved. One thing is blocking the merge though: To unblock, sign the commit and force-push: git commit --amend -S --no-edit
git push --force-with-leaseThat needs commit signing configured (a GPG or SSH signing key + Once the commit shows as Verified, this is good to merge. |
4f1c9b5 to
3a5d8c0
Compare
loadBpmDetective cached the promise returned by dynamic import even when that import rejected. A transient failure (network hiccup, bundler issue, missing module at first access) was therefore cached as null for the rest of the session, silently disabling BPM detection. - Reset the cached promise on import failure so the next call retries. - Only cache the default production import; custom loaders bypass the cache. - Make loadBpmDetective testable by accepting an optional importFn. - Add regression tests for failure/retry and module/default resolution.
3a5d8c0 to
920b0e3
Compare
Problem
beatDetection.tsimportedbpm-detectivevia dynamicimport()and the failure was cached. If the first attempt failed due to a transient build/install issue, the module never loaded again in the same process.Triage / Root cause
Node/V8 caches failed dynamic imports, so
await import('bpm-detective')on a broken first attempt would keep rejecting without re-reading from disk.Fix
bpm-detectivebefore retrying.analyzeAudioreadable.packages/core/src/beats/beatDetection.test.ts.Verification
bun test packages/core/src/beats/beatDetection.test.tspassed.bunx oxlintandbunx oxfmt --checkpassed on changed files.Notes / Risks
Only affects the first import attempt in a long-running process; subsequent uses are still cached on success.