fix: reset pending state after leading-only debouncer execution - #234
fix: reset pending state after leading-only debouncer execution#234Don-Erfan wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 4 reviews per rolling hour; 3 remain after this review. 📝 WalkthroughWalkthroughBoth debouncer implementations now prevent leading-edge calls from running again through trailing execution or ChangesDebouncer leading-edge behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change resets debouncer state correctly after a leading-edge execution and prevents stale re-execution through flush; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
🎯 Changes
With
leading: trueandtrailing: true, a single call tomaybeExecuteexecuted on the leading edge but still setisPending: trueand storedlastArgs. The trailing timeout correctly skips calls already handled by the leading edge, so nothing ever reset that state: status stayed'pending'forever, and a laterflush()re-executed the function with stale, already-executed arguments.Fix
isPending/lastArgsfor calls that were not consumed by the leading edge, so the debouncer returns to'idle'after a single execution.LiteDebouncer, which storedlastArgsunconditionally and could therefore re-execute a leading-edge call viaflush().Tests
flush()behavior after a leading-edge call, pending state, and idle transitions.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
flush()behavior so it no longer re-executes completed leading-edge calls.Tests
flush(), pending state, and idle transitions.