What is currently-unhandled?
The currently-unhandled npm package is used to track unhandled promise rejections in Node.js. It provides a way to log or handle promise rejections that might otherwise go unnoticed. This can be particularly useful for debugging and for applications that need to ensure all errors are accounted for.
What are currently-unhandled's main functionalities?
Tracking unhandled rejections
This feature allows you to track unhandled promise rejections. By using the currentlyUnhandled() function, you can retrieve an array of promises that were rejected and not yet handled at the time of the call.
const currentlyUnhandled = require('currently-unhandled')();
process.on('unhandledRejection', (reason, promise) => {
console.log('Unhandled Rejection at:', promise, 'reason:', reason);
// Application specific logging, throwing an error, or other logic here
});
// Later in the code, you can check for unhandled rejections
const unhandledRejections = currentlyUnhandled();
console.log(unhandledRejections);
Other packages similar to currently-unhandled
bluebird
Bluebird is a full-featured promise library with a focus on innovative features and performance. It includes built-in support for catching unhandled rejections, similar to currently-unhandled, but it is a more comprehensive promise handling library.
when
When is a lightweight Promises/A+ and when() implementation. It provides utilities for working with promises including chaining, transforming, and handling unhandled rejections, offering similar functionalities but as part of a larger set of promise-related tools.
q
Q is a tool for making and composing asynchronous promises in JavaScript. It has a method for handling unhandled rejections, similar to currently-unhandled, but it also provides a wide array of features for promise creation and manipulation.
currently-unhandled

Track the list of currently unhandled promise rejections.
Install
$ npm install --save currently-unhandled
Usage
const currentlyUnhandled = require('currently-unhandled')();
var fooError = new Error('foo');
var p = Promise.reject(new Error('foo'));
currentlyUnhandled();
p.catch(() => {});
currentlyUnhandled();
API
currentlyUnhandled()
Returns an array of objects with promise
and reason
properties representing the rejected promises that currently do not have a rejection handler. The list grows and shrinks as unhandledRejections are published, and later handled.
Browser Support
This module can be bundled with browserify
. At time of writing, it will work with native Promises in the Chrome browser only. For best cross-browser support, use bluebird
instead of native Promise support in browsers.
License
MIT © James Talmage