
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
@fortify-ts/circuit-breaker
Advanced tools
Circuit breaker pattern implementation for the Fortify-TS resilience library.
npm install @fortify-ts/circuit-breaker
# or
pnpm add @fortify-ts/circuit-breaker
readyToTrip and isSuccessful callbacksonStateChange callbackimport { CircuitBreaker } from '@fortify-ts/circuit-breaker';
const breaker = new CircuitBreaker<Response>({
maxFailures: 5,
timeout: 60000, // 60 seconds
});
try {
const result = await breaker.execute(async (signal) => {
return fetch('/api/data', { signal });
});
} catch (error) {
if (error instanceof CircuitOpenError) {
console.log('Circuit is open, try again later');
}
}
const breaker = new CircuitBreaker<Response>({
// Maximum failures before opening circuit
maxFailures: 5,
// Time in ms before attempting recovery
timeout: 60000,
// Requests allowed in half-open state
halfOpenMaxRequests: 1,
// Reset counts interval (0 = disabled)
interval: 0,
// Custom trip condition
readyToTrip: (counts) => counts.consecutiveFailures >= 3,
// Custom success condition
isSuccessful: (result) => result.ok,
// State change notification
onStateChange: (from, to) => {
console.log(`Circuit state: ${from} -> ${to}`);
},
// Optional logger
logger: myLogger,
});
┌─────────────────────────────────────────────────┐
│ │
▼ │
CLOSED ──── failures >= maxFailures ────► OPEN ────►│
▲ │ │
│ │ timeout
│ ▼ │
└────── success ◄──────────────────── HALF-OPEN ─┘
│
│ failure
▼
OPEN
// Get current state
const state = breaker.getState(); // 'closed' | 'open' | 'half-open'
// Get request counts
const counts = breaker.getCounts();
console.log(counts.requests, counts.totalSuccesses, counts.totalFailures);
// Reset circuit breaker
breaker.reset();
// Clean up resources
await breaker.close();
| Option | Type | Default | Description |
|---|---|---|---|
maxFailures | number | 5 | Failures before opening |
timeout | number | 60000 | Recovery timeout (ms) |
halfOpenMaxRequests | number | 1 | Requests in half-open |
interval | number | 0 | Count reset interval |
readyToTrip | function | - | Custom trip condition |
isSuccessful | function | - | Custom success check |
onStateChange | function | - | State change callback |
logger | FortifyLogger | - | Optional logger |
MIT
FAQs
Circuit breaker pattern for Fortify TS resilience library
We found that @fortify-ts/circuit-breaker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.