npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

await-leak-detector

v0.2.0

Published

Detect unhandled async/await calls and Promise leaks in JavaScript applications

Readme

awaitly

awaitly (npm: await-leak-detector) is a small development-time utility that helps you catch un-awaited Promises — a common cause of hidden async leaks, hanging tests, and “nothing happens but no error” bugs.

It works by temporarily instrumenting global.Promise, tracking newly created Promises, and warning you when a promise stays pending beyond a configured timeout.

⚠️ Use only in development/test environments. This package overrides the global Promise constructor, which can affect other libraries. Never enable it in production builds.


🚀 Installation

npm install await-leak-detector

🟦 Quick Example (Node.js)

// example/node-demo.js
const awaitLeak = require("await-leak-detector");

// Start tracking (defaults: timeout 5000ms, interval 1000ms)
awaitLeak.enable();

// Create an un-awaited Promise (simulated leak)
new Promise(() => {});

// Stop tracking when done (important in automated tests)
awaitLeak.disable();

🟩 Usage in React (Browser)

Enable it only during development:

// src/setupAwaitly.js
import awaitLeak from "await-leak-detector";

if (process.env.NODE_ENV === "development") {
  awaitLeak.enable({
    timeoutMs: 2000,   // how long to wait before reporting a leak
    intervalMs: 500    // how frequently to scan pending promises
  });
}

Then import this early in your app entry point:

// src/index.js
import "./setupAwaitly";

This ensures promises created during app bootstrap are also tracked.


📚 API Reference

awaitLeak.enable([options])

Starts tracking newly created promises.

Options:

  • timeoutMs (number) – how long a promise can stay pending before it’s considered a leak default: 5000
  • intervalMs (number) – how often the system checks for pending promises default: 1000

You can call this in three ways:

awaitLeak.enable();                          // use defaults
awaitLeak.enable(3000);                      // timeout only
awaitLeak.enable({ timeoutMs: 3000 });       // options object
awaitLeak.enable({ timeoutMs: 3000, intervalMs: 500 });

awaitLeak.disable()

Stops tracking, restores the original global Promise, and clears any internal state.

Use this when:

  • Your test has finished running
  • You want to temporarily turn off the leak detector
  • You want to re-enable with different options

Diagnostics (awaitLeak.tracker)

awaitLeak.tracker.getPendingCount();   // number of tracked pending promises
awaitLeak.tracker.getPendingTraces();  // traces associated with each pending promise
awaitLeak.tracker.clear();             // reset internal state

These helpers are useful for testing or for custom tooling.


⚠️ Important Warning

awaitly monkey-patches the global Promise object. While safe for local development, this can:

  • Interfere with polyfills or shims
  • Affect some 3rd-party libraries that extend Promise
  • Cause unpredictable behavior in production builds

👉 Use it ONLY for debugging or testing, never in production apps.