Skip to content

[FEATURE][BUGFIX] Add error handling, batch resilience demo, and fix batch resolver error propagation#24

Merged
JaysonGCS merged 5 commits into
mainfrom
feat/error-handling-and-demo
May 15, 2026
Merged

[FEATURE][BUGFIX] Add error handling, batch resilience demo, and fix batch resolver error propagation#24
JaysonGCS merged 5 commits into
mainfrom
feat/error-handling-and-demo

Conversation

@JaysonGCS

Copy link
Copy Markdown
Contributor

Description

This PR fixes a critical error handling gap in the MicroBatcher library where batch resolver failures would leave caller promises hanging indefinitely, and adds comprehensive error simulation scenarios to the demo app to showcase batch-level fault isolation.

Changes Made

Library Fixes

  • Batch resolver error propagation — Added .catch() to the batch resolver promise chain so that when a batch resolver rejects, all caller promises in that batch are properly rejected instead of hanging forever
  • Error re-throw — Changed throw Error(e) to throw e to preserve the original error type and stack trace
  • Type fix — Corrected PromiseLock.reject callback parameter type from O to any

Test Coverage

  • Added test for batch resolver rejection propagating errors to all callers
  • Added test for mismatched result count propagating errors to all callers
  • Replaced all deprecated toBeCalledTimes/toBeCalledWith with toHaveBeenCalledTimes/toHaveBeenCalledWith

Demo App Rewrite

  • Replaced Recoil-based demo with React context + TailwindCSS playground
  • Added four error simulation modes: None, All Reject, Result Mismatch, and Random Batch Reject
  • Switched experiment runner from Promise.all to Promise.allSettled to capture partial results
  • Added SecurityResult discriminated union type for per-cusip success/error state
  • Security cards render as indigo (success) or red (failed) to visually demonstrate batch isolation — when one batch fails, other batches still return results
  • Added color-coded event log with error type support

Documentation

  • Updated README to remove Recoil references
  • Replaced Recoil selectorFamily example with drop-in replacement snippet
  • Added mention of error handling and batch resilience demos

Definition of Done

  • All automated tests have passed successfully.
  • All manual tests have passed successfully.
  • Code has been reviewed by at least one other team member.
  • Code has been properly documented and commented as needed.
  • All new and existing code adheres to our project's coding standards.
  • All dependencies have been added or removed from the project's README or other documentation as needed.

JaysonGCS added 5 commits May 15, 2026 16:32
- Add .catch() to batch resolver promise chain to reject all caller
  promises when the batch resolver fails
- Re-throw original error instead of wrapping with Error()
- Fix PromiseLock.reject callback type from generic O to any

Signed-off-by: JaysonGCS <goh.chung.sern@gmail.com>
…hers

- Add test for batch resolver rejection propagating to all callers
- Add test for mismatched result count propagating to all callers
- Replace deprecated toBeCalledTimes/toBeCalledWith with
  toHaveBeenCalledTimes/toHaveBeenCalledWith throughout

Signed-off-by: JaysonGCS <goh.chung.sern@gmail.com>
- Replace Recoil-based demo with React context + TailwindCSS playground
- Add configurable error simulation modes: all reject, result mismatch,
  and random batch reject (~50% failure per batch)
- Use Promise.allSettled to capture partial results from independent
  batches, showcasing MicroBatcher batch isolation resilience
- Add SecurityResult discriminated union for per-cusip success/error state
- Render mixed success (indigo) and error (red) security cards
- Add event log with color-coded entries including error type
- Update project infra: pnpm workspace, lockfiles, husky pre-commit

Signed-off-by: JaysonGCS <goh.chung.sern@gmail.com>
…ndling

- Replace Recoil-specific webapp description with general playground description
- Replace Recoil selectorFamily example with drop-in replacement snippet
- Mention error handling scenarios and batch resilience demonstrations

Signed-off-by: JaysonGCS <goh.chung.sern@gmail.com>
Signed-off-by: JaysonGCS <goh.chung.sern@gmail.com>
@JaysonGCS JaysonGCS merged commit a4795a1 into main May 15, 2026
9 checks passed
JaysonGCS added a commit that referenced this pull request May 15, 2026
Triggers release for changes in #24:
- Fix batch resolver error propagation to all callers
- Add error simulation playground to demo app
- Add batch resilience demonstration with partial failure support

Signed-off-by: JaysonGCS <goh.chung.sern@gmail.com>
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant