Skip to content

feat(async/unstable): enhance CircuitBreaker with AbortSignal and onHalfOpen callback#6951

Merged
kt3k merged 10 commits intodenoland:mainfrom
tomas-zijdemans:halfopen-callback
Jan 23, 2026
Merged

feat(async/unstable): enhance CircuitBreaker with AbortSignal and onHalfOpen callback#6951
kt3k merged 10 commits intodenoland:mainfrom
tomas-zijdemans:halfopen-callback

Conversation

@tomas-zijdemans
Copy link
Contributor

@tomas-zijdemans tomas-zijdemans commented Jan 12, 2026

  • Simplified API: removed isAvailable, failureCount, getStats
  • Added onHalfOpen callback for complete state observability
  • Added signal option in execute() for AbortSignal support
  • Changed validation errors from TypeError to RangeError (aligns with stable @std/async)
  • Improved timestamp consistency
  • Improved typing
  • Updated docs and tests

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.08%. Comparing base (007896d) to head (9d91c79).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6951      +/-   ##
==========================================
- Coverage   94.09%   94.08%   -0.01%     
==========================================
  Files         600      600              
  Lines       43565    43553      -12     
  Branches     6999     6997       -2     
==========================================
- Hits        40991    40976      -15     
- Misses       2519     2521       +2     
- Partials       55       56       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomas-zijdemans tomas-zijdemans changed the title feat(async/unstable): enhance CircuitBreaker with AbortSignal, onHalfOpen, and align error types feat(async/unstable): enhance CircuitBreaker with AbortSignal and onHalfOpen callback Jan 13, 2026
Add optional AbortSignal to CircuitBreaker.execute() for pre-flight
abort checking. This enables timeout and graceful shutdown scenarios
when composing with other async primitives like retry().

- Add CircuitBreakerExecuteOptions interface with signal property
- Check signal.throwIfAborted() before executing the function
- Aborts do not count as circuit failures
- Update JSDoc examples to show realistic usage patterns
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kt3k kt3k merged commit 062aa94 into denoland:main Jan 23, 2026
19 checks passed
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.

2 participants