Skip to content

✨ Quality: Improve robustness and documentation of AsyncBlock - #85

Merged
galiprandi merged 1 commit into
mainfrom
quality/async-block-improvements-14959684732361421922
Jun 10, 2026
Merged

✨ Quality: Improve robustness and documentation of AsyncBlock#85
galiprandi merged 1 commit into
mainfrom
quality/async-block-improvements-14959684732361421922

Conversation

@galiprandi

Copy link
Copy Markdown
Owner

💡 What: The quality improvement added

Implemented several enhancements to the AsyncBlock component:

  • Race Condition Fix: Updated the .catch block logic to use signal.reason to 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.
  • API Flexibility: Made the error prop optional in AsyncBlockProps, allowing consumers to omit it if they don't need a specific error UI.
  • Documentation: Added detailed JSDoc for the component and all its props, including a template parameter and usage examples.
  • Test Coverage: Added new tests to verify the race condition fix and the optional error prop 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 error prop that wasn't always necessary.

📊 Impact: How it improves the codebase

  • Increased Robustness: Fewer UI glitches during rapid dependency changes.
  • Better Developer Experience: Clearer documentation and examples make the component easier to adopt.
  • Higher Maintainability: The test suite is more robust and isolated.

✅ Verification: How to verify it works

Run pnpm test lib/components/AsyncBlock/index.test.tsx to verify the new and existing tests pass.
Run pnpm lint to ensure the changes follow the project's coding standards.


PR created automatically by Jules for task 14959684732361421922 started by @galiprandi

- 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.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@galiprandi
galiprandi merged commit ae0f13a into main Jun 10, 2026
4 checks passed
@galiprandi
galiprandi deleted the quality/async-block-improvements-14959684732361421922 branch June 15, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant