opossum: A Robust Node.js Circuit Breaker for Resilient Applications
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
opossum is a robust Node.js circuit breaker designed to enhance application resilience. It intelligently monitors asynchronous function executions, failing fast to prevent cascading failures when services are unstable. This library provides essential features like fallbacks and state management, ensuring your systems remain stable and responsive.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
opossum is a robust Node.js circuit breaker designed to enhance the resilience of your applications. It intelligently executes asynchronous functions and monitors their execution status, playing dead and failing fast when issues arise. This prevents cascading failures, ensuring your system remains stable and responsive even when dependent services are experiencing problems.
With over 1560 stars and 112 forks on GitHub, opossum is a well-regarded solution for implementing the circuit breaker pattern in Node.js environments. It offers features like configurable timeouts, error thresholds, and reset mechanisms, along with support for fallback functions and event-driven monitoring.
Installation
To integrate opossum into your Node.js project, simply install it via npm:
npm install opossum
Please note that opossum requires Node.js version 20 or higher.
Examples
Here's a basic example demonstrating how to use opossum to wrap an asynchronous function that might fail:
const CircuitBreaker = require('opossum');
function asyncFunctionThatCouldFail(x, y) {
return new Promise((resolve, reject) => {
// Simulate an operation that might fail or take time
if (Math.random() > 0.5) {
setTimeout(() => resolve(`Success with ${x}, ${y}`), 100);
} else {
setTimeout(() => reject(new Error(`Failure with ${x}, ${y}`)), 50);
}
});
}
const options = {
timeout: 3000, // If our function takes longer than 3 seconds, trigger a failure
errorThresholdPercentage: 50, // When 50% of requests fail, trip the circuit
resetTimeout: 30000 // After 30 seconds, try again.
};
const breaker = new CircuitBreaker(asyncFunctionThatCouldFail, options);
breaker.fire('arg1', 'arg2')
.then(console.log)
.catch(console.error);
You can also define a fallback function to provide a graceful degradation experience when the circuit is open:
const breakerWithFallback = new CircuitBreaker(asyncFunctionThatCouldFail, options);
breakerWithFallback.fallback(() => 'Sorry, the service is currently unavailable.');
breakerWithFallback.fire('arg1', 'arg2')
.then(console.log)
.catch(console.error);
Why Use opossum?
Implementing a circuit breaker like opossum offers significant advantages for modern distributed applications:
- Prevents Cascading Failures: By isolating failing services, opossum stops errors from propagating throughout your system, protecting healthy parts of your application.
- Improves Fault Tolerance: Your application becomes more resilient to transient failures in external dependencies, maintaining functionality even under stress.
- Graceful Degradation: Fallback functions allow you to provide alternative responses or default data when a service is unavailable, enhancing user experience.
- Real-time Monitoring: opossum emits various events (
open,close,failure,success,timeout, etc.) that enable real-time monitoring and alerting on service health. - Performance Optimization: Features like call coalescing can significantly improve performance by grouping multiple identical requests within a short timeframe.
- Browser Support: opossum can also be used in browser environments to guard against network failures in AJAX calls, making it versatile for full-stack resilience.
- Metrics Integration: Easily integrate with monitoring tools like Prometheus via opossum-prometheus or Hystrix Dashboard via opossum-hystrix for comprehensive insights.
Links
- GitHub Repository: https://github.com/nodeshift/opossum
- Documentation: https://nodeshift.dev/opossum/
- Typings: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/opossum
- Issue Tracker: https://github.com/nodeshift/opossum/issues
- Prometheus Integration: https://github.com/nodeshift/opossum-prometheus
- Hystrix Integration: https://github.com/nodeshift/opossum-hystrix
Related repositories
Similar repositories that may be relevant next.
Agent-Memory: Persistent Memory for AI Coding Agents
August 16, 2026
Agent-Memory provides persistent memory for AI coding agents, ensuring they remember past interactions and learned patterns across sessions. Built on the iii engine, it eliminates the need for re-explaining context, significantly improving agent efficiency and reducing token usage. This solution integrates seamlessly with various agents, offering a robust memory management system.

Flask-Assets: Seamless Asset Management for Flask Applications
July 26, 2026
Flask-Assets provides robust integration of the `webassets` library with Flask. It simplifies the process of merging, minifying, and compiling CSS and JavaScript files, significantly enhancing web application performance and streamlining development workflows.

webassets: Asset Management for Python Web Development
July 26, 2026
webassets is a robust library designed for asset management in Python web development. It simplifies the process of merging and compressing JavaScript and CSS files, enhancing application performance. This tool is essential for developers looking to optimize their frontend assets efficiently.

Become-A-Full-Stack-Web-Developer: Free Resources for Web Development
July 19, 2026
The Become-A-Full-Stack-Web-Developer repository is an extensive collection of free resources designed to guide aspiring developers through the entire journey of full-stack web development. It covers a wide array of topics, from foundational languages like HTML, CSS, and JavaScript to advanced frameworks such as React and Node.js, alongside databases, APIs, and career preparation. This resource is invaluable for anyone looking to build a strong skill set in modern web development.
Source repository
Open the original repository on GitHub.
10 counted GitHub visits