promise-debug

Got an unhandled promise rejection you can't find? This lib is for you.

2 个版本
安装
npm install promise-debug
yarn add promise-debug
pnpm add promise-debug
bun add promise-debug
README

promise-debug

Wraps JavaScript promises to add ids, original stack traces, and readable output

Usage

global.Promise = require('promise-debug');

Now, your promises will have several new properties:

  • id: a unique identifier for the promise
  • originalStack: the stack trace when the promise constructor was called
  • executor: the executor function

To print out the stack trace for a promise with an unhandled rejection, use this:

process.on('unhandledRejection', (err, promise) => {
  console.log('UnhandledRejection:', promise.originalStack);
});
版本列表
0.1.1 2018-10-07
0.1.0 2018-10-05