Socket
Book a DemoInstallSign in
Socket

uncaughts

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uncaughts

Cleanly register uncaughtException and unhandledRejection handlers

latest
Source
npmnpm
Version
1.1.3
Version published
Weekly downloads
1.2K
35.97%
Maintainers
2
Weekly downloads
 
Created
Source

Uncaughts

Cleanly register uncaughtException and unhandledRejection handlers, using a single handler for both.

Supports Node.js and Bare.

Install

npm i uncaughts

Usage

const uncaughts = require('uncaughts')

const handler = () => {
  console.log('I run when an uncaught exception or unhandled rejection triggers')
}

uncaughts.on(handler)

// ... (uncaughts/unhandleds do not bubble up, but the handler runs instead)

// Remove the handler. Uncaughts/unhandleds will bubble up again
uncaughts.off(handler)

This module also exposes uncaughts.once, which removes the handlers after it triggered once (just like Node's Events.once(...)). However, using this API is not recommended, since it rarely makes sense to only handle one unhandled rejection or uncaught exception. Furthermore, there can be subtle differences in behaviour between Node.js and Bare.

Keywords

uncaughtException

FAQs

Package last updated on 07 Nov 2025

Did you know?

Socket

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