✨ Quality: Improve robustness and documentation of AsyncBlock - #85
Conversation
- Fix race condition by distinguishing between manual and timeout aborts in `AsyncBlock`. - Update `AsyncBlockProps` to make the `error` prop optional. - Add comprehensive JSDoc documentation with examples for `AsyncBlock`. - Enhance test suite with race condition and optional prop test cases. - Add `vi.restoreAllMocks()` for better test isolation in `AsyncBlock` tests.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: The quality improvement added
Implemented several enhancements to the
AsyncBlockcomponent:.catchblock logic to usesignal.reasonto distinguish between manual aborts (from dependency changes/unmounts) and timeout aborts. This prevents the component from incorrectly showing an error state when it's just being re-triggered or unmounted.errorprop optional inAsyncBlockProps, allowing consumers to omit it if they don't need a specific error UI.errorprop behavior. Improved existing tests with proper mock cleanup.🎯 Why: The quality gap it addresses
The previous implementation had a potential race condition where aborted promises could overwrite the state of a new request. Additionally, the component was lackings sufficient documentation and had a strictly required
errorprop that wasn't always necessary.📊 Impact: How it improves the codebase
✅ Verification: How to verify it works
Run
pnpm test lib/components/AsyncBlock/index.test.tsxto verify the new and existing tests pass.Run
pnpm lintto ensure the changes follow the project's coding standards.PR created automatically by Jules for task 14959684732361421922 started by @galiprandi