Skip to content

fix(async/unstable): count circuit breaker requests at completion - #7307

Open
tomas-zijdemans wants to merge 1 commit into
denoland:mainfrom
tomas-zijdemans:fix-cb-count-at-completion
Open

fix(async/unstable): count circuit breaker requests at completion#7307
tomas-zijdemans wants to merge 1 commit into
denoland:mainfrom
tomas-zijdemans:fix-cb-count-at-completion

Conversation

@tomas-zijdemans

Copy link
Copy Markdown
Contributor

The circuit breaker counted a request when it was admitted but counted its failure when it completed, and the failure path never rotated the sliding window. Two things went wrong across an await:

  • A request admitted in one window could fail in the next. After another request rotated the counters, the failure landed with no matching request. Two slow failures after one fresh success reported 2 failures against 1 request and opened the circuit.
  • A delayed failure was evaluated against unrotated history, so failures that had already expired still counted toward the rate.

Requests are now counted on completion, right after rotating, so a request and its outcome always land in the same segment. Callbacks still report the same totals for requests that complete in order.

Two tests cover the mismatch and the stale history. Both fail on main.

@github-actions github-actions Bot added the async label Sep 6, 2026
@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.03%. Comparing base (ca58f94) to head (0cf01a7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7307   +/-   ##
=======================================
  Coverage   95.03%   95.03%           
=======================================
  Files         617      617           
  Lines       51637    51641    +4     
  Branches     9359     9359           
=======================================
+ Hits        49075    49079    +4     
  Misses       2021     2021           
  Partials      541      541           

☔ View full report in Codecov by Harness.
📢 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.

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