fix: correct maybeExecuteCount increment and add test for AbortSignal…#187
fix: correct maybeExecuteCount increment and add test for AbortSignal…#187MrPorky wants to merge 2 commits intoTanStack:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughFixes an execution ID mismatch in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/pacer/tests/async-debouncer.test.ts (1)
1362-1377: Test name overstates behavior; cancellation is not asserted.This test currently verifies signal availability, not cancellation. Consider asserting abort semantics (
debouncer.abort()+signal.aborted/abort listener) to match the test intent.✅ Suggested test tightening
- it('should return an AbortSignal that can be used to cancel execution', async () => { + it('should return an AbortSignal and mark it aborted when abort() is called', async () => { const debouncer = new AsyncDebouncer( async () => { const signal = debouncer.getAbortSignal() expect(signal).toBeInstanceOf(AbortSignal) + expect(signal?.aborted).toBe(false) return 'result' }, { wait: 300 }, ) - debouncer.maybeExecute() + debouncer.maybeExecute() vi.advanceTimersByTime(150) const promise = debouncer.maybeExecute() vi.advanceTimersByTime(300) + debouncer.abort() + expect(debouncer.getAbortSignal()?.aborted ?? true).toBe(true) await promise })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/pacer/tests/async-debouncer.test.ts` around lines 1362 - 1377, The test name claims cancellation behavior but only checks that getAbortSignal() returns an AbortSignal; update the test for AsyncDebouncer to actually assert abort semantics by invoking debouncer.abort() (or triggering cancellation via the API), then asserting the returned signal from debouncer.getAbortSignal() becomes aborted (signal.aborted true) and/or that an abort event listener is invoked; reference the AsyncDebouncer class and its methods maybeExecute, getAbortSignal, and abort to locate the change and add assertions that verify the signal was aborted after calling abort().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/pacer/tests/async-debouncer.test.ts`:
- Around line 1362-1377: The test name claims cancellation behavior but only
checks that getAbortSignal() returns an AbortSignal; update the test for
AsyncDebouncer to actually assert abort semantics by invoking debouncer.abort()
(or triggering cancellation via the API), then asserting the returned signal
from debouncer.getAbortSignal() becomes aborted (signal.aborted true) and/or
that an abort event listener is invoked; reference the AsyncDebouncer class and
its methods maybeExecute, getAbortSignal, and abort to locate the change and add
assertions that verify the signal was aborted after calling abort().
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7ba60ee3-9931-4ff6-83e4-74ed1848e762
📒 Files selected for processing (3)
.changeset/humble-coats-shop.mdpackages/pacer/src/async-debouncer.tspackages/pacer/tests/async-debouncer.test.ts
🎯 Changes
This PR fixes an issue in
AsyncDebouncerwhere callingdebouncer.getAbortSignal()incorrectly returnsnull, preventing consumers from properly attaching abort signals to underlying async operations.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests