Socket
Socket
Sign inDemoInstall

currently-unhandled

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    currently-unhandled

Track the list of currently unhandled promise rejections.


Version published
Weekly downloads
4M
decreased by-1.94%
Maintainers
1
Install size
10.3 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

currently-unhandled Build Status Coverage Status

Track the list of currently unhandled promise rejections.

Install

$ npm install --save currently-unhandled

Usage

const currentlyUnhandled = require('currently-unhandled')(); // <- note the invocation

var fooError = new Error('foo');
var p = Promise.reject(new Error('foo'));

// on the next tick - unhandled rejected promise is added to the list:
currentlyUnhandled();
//=> [{promise: p, reason: fooError}]'

p.catch(() => {});

// on the next tick - handled promise is now removed from the list:
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

Keywords

FAQs

Last updated on 02 Jun 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc