-
-
Notifications
You must be signed in to change notification settings - Fork 185
feat: allow failureThreshold to be zero or above 100 #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,7 +245,8 @@ export async function recordFailure(providerId: number, error: Error): Promise<v | |
| ); | ||
|
|
||
| // 检查是否需要打开熔断器 | ||
| if (health.failureCount >= config.failureThreshold) { | ||
| // failureThreshold = 0 表示禁用熔断器 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] [TEST-MISSING-CRITICAL] No tests for critical circuit breaker behavior change Why this is a problem: This change adds a critical condition that allows Suggested fix: Add unit tests covering these cases: // tests/unit/circuit-breaker.test.ts
describe('circuit breaker with threshold = 0', () => {
it('should never open circuit when threshold is 0', async () => {
// Set failureThreshold = 0
// Record 100 failures
// Verify circuit remains closed
});
});
describe('circuit breaker with threshold > 100', () => {
it('should function normally with high threshold values', async () => {
// Set failureThreshold = 150
// Record 149 failures - circuit should stay closed
// Record 150th failure - circuit should open
});
});Without tests, we cannot verify this critical behavior works correctly across application restarts, Redis failures, or concurrent requests. |
||
| if (config.failureThreshold > 0 && health.failureCount >= config.failureThreshold) { | ||
| health.circuitState = "open"; | ||
| health.circuitOpenUntil = Date.now() + config.openDuration; | ||
| health.halfOpenSuccessCount = 0; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.