Skip to content

fix(combo): cancel set-retry waits promptly - #18549

Merged
diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.53from
AiCaptain357:fix/combo-set-retry-cancellation
Nov 4, 2026
Merged

diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.53from
AiCaptain357:fix/combo-set-retry-cancellation

Conversation

@AiCaptain357

Copy link
Copy Markdown
Contributor

With set retries enabled, cancellation just before the next retry wait can leave a request waiting for its entire configured delay before returning 499. A normally expired wait also leaves its abort listener attached to the request signal.

Reuse the existing cancellation-aware wait helper. Keep a timer turn for zero-delay retries so queued cancellation can run before another dispatch. Retry limits and the existing 499 response are preserved.

Proof of fix

Four regression scenarios fail on pristine release/v3.8.53 at 6ecb2090 and pass with the fix. They exercise the real handleComboChat handler with synthetic upstream responses, covering cancellation before the wait and listener cleanup after success or exhaustion. Cancellation during a wait, dispatch counts and zero-delay behavior are also checked.

Updated test: tests/unit/combo-loop-safety-timer-cleanup.test.ts.

Validation

  • Handler tests: 20/20; nearby tests: 14/14; combo routing matrix: 40/40.
  • Scoped ESLint, Prettier, whitespace checks and pre-commit hooks pass. The private UI-kit snapshot gate skips because its reference clone is unavailable.
  • Full lint exceeded a 300-second local budget. Full unit/Vitest suites, typecheck and application build were not run; those checks remain for CI.

Related: #17885 fixed separate loop-safety timers. This patch covers the delay between sets.

Target: release/v3.8.53.

⚠️ base-red inherited: #17219. The target release branch already has unrelated failing checks tracked in that issue.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Combo-set retries now stop immediately when a request has already been cancelled, returning the expected cancellation response.
    • Cancellation during a retry delay is handled reliably, and retry attempts continue to yield before dispatching—even when the delay is zero.
    • Retry and safety timers are cleaned up across cancellation, retries, and other terminal outcomes.

The combo-set retry loop now uses a cooldown-aware wait with a minimum delay of 1 ms. Tests cover cancellation and cleanup during retry delays, pre-aborted requests, successful retries, and retry exhaustion.

Changes: Combo Retry Cancellation

Layer / File(s) Summary
Cooldown-aware retry wait
open-sse/services/combo/comboAttemptLoop.ts, changelog.d/fixes/0-combo-set-retry-cancellation.md
The retry loop uses waitForCooldownAwareRetry with a minimum delay of 1 ms. The existing abort check and 499 response remain in place. The changelog describes cancellation handling, listener cleanup, and yielding before zero-delay retries.
Retry timer and cancellation tests
tests/unit/combo-loop-safety-timer-cleanup.test.ts
Controlled retry timers support tests for cancellation, pre-aborted requests, successful retries, and retry exhaustion. The tests check timer and abort-listener cleanup.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · up to efaa3

Retry waits now handle cancellation and preserve the 499 response. No merge-blocking risk was established; run the usual CI checks.

Pre-merge checks: Passed 6 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 6 passed
Check name Status Explanation
Title check Passed The title follows the Conventional Commits form fix(combo): ... with an allowed type. It names the main change: set-retry waits now cancel promptly, which matches the comboAttemptLoop.ts change that…
Description check Passed The description covers the problem, the fix, proof of fix, validation, and related issues. It follows the template's main sections (Summary, Validation, Tests Added Or Updated via the updated test fil…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Tests For Production Code Passed The PR changes production code in open-sse/services/combo/comboAttemptLoop.ts. It also updates tests/unit/combo-loop-safety-timer-cleanup.test.ts with retry-timer tracking and regression tests for…
No Ai Attribution Passed PASS. All three reviewed commits have no trailers, and no commit message contains a Co-Authored-By trailer or a Generated with footer. The authored PR body also contains neither prohibited attribu…
Full details: Title check

Explanation

The title follows the Conventional Commits form fix(combo): ... with an allowed type. It names the main change: set-retry waits now cancel promptly, which matches the comboAttemptLoop.ts change that routes the set-retry delay through the cancellation-aware wait helper.

Full details: Description check

Explanation

The description covers the problem, the fix, proof of fix, validation, and related issues. It follows the template's main sections (Summary, Validation, Tests Added Or Updated via the updated test file, Target Branch via the stated release base). Gaps: the Related Issues section does not use the Closes # or Related to # format, and the Target Branch checklist is not ticked. The Coverage Notes and Reviewer Notes sections are not addressed explicitly. The author states the target is release/v3.8.53, while the template requires the active release/v3.8.x branch, which the author should confirm.

Full details: Tests For Production Code

Explanation

The PR changes production code in open-sse/services/combo/comboAttemptLoop.ts. It also updates tests/unit/combo-loop-safety-timer-cleanup.test.ts with retry-timer tracking and regression tests for pre-abort, expired waits, and zero-delay cancellation.

Full details: No Ai Attribution

Explanation

PASS. All three reviewed commits have no trailers, and no commit message contains a Co-Authored-By trailer or a Generated with footer. The authored PR body also contains neither prohibited attribution.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 3
  • Waived: $0.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f000c11 and efaa384.

Files selected for processing: 3
  • changelog.d/fixes/0-combo-set-retry-cancellation.md
  • open-sse/services/combo/comboAttemptLoop.ts
  • tests/unit/combo-loop-safety-timer-cleanup.test.ts

Limit details: You’ve used all 10 included reviews currently available.

@diegosouzapw
diegosouzapw merged commit 8d41e9c into cheaper-inference:release/v3.8.53 Nov 4, 2026
36 of 38 checks passed
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.

2 participants