Repository navigation
fix: don't call a hookOnce callback twice for overlapping callHook calls - #172
deepanshupal wants to merge 2 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthrough
ChangeshookOnce concurrency
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change prevents duplicate one-shot callbacks during overlapping calls while preserving sequential behavior. No actionable merge risk remains in the reviewed change. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The change prevents duplicate callback execution without expanding caller permissions. The reviewed callback lifecycle introduces no material security risk. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 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 |
resolves #171
hookOncewrapper now no-ops when invoked again after its first call. A concurrentcallHookcan hold a stale snapshot of the hook list (taken before the first call unregistered the wrapper, e.g. while queued behind an async hook), and previously the second invocation fell through to calling the user's callback again._unreg?.(), which keeps the minifiednew Hookable()bundle smaller than base (2988 bytes, budget 3000) even with the added guard.Tests (
test/hookable.test.ts):hookOncecallback plus two overlappingcallHookpromises fires the callback exactly once (fails pre-fix withx = 2).Verification against base 6815e4f (main, v6.1.2): new test fails pre-fix and passes post-fix; full
vitest run --coverage45/45 across all 4 files including bundle-size budgets;tsc --noEmit,oxlint, andoxfmt --checkall clean.Summary by CodeRabbit