Skip to content Skip to sidebar Skip to footer

Tracking/logging Promises

I am trying to find a solution for tracking Promises. The project that I am working on has some dangling async tasks that are not awaited/yielded. I am trying to find such cases, a

Solution 1:

You can monkey patch the promise constructor like this:

constglobal = window; // (in browser...)constOldPromise = global.Promise; 
global.Promise = classPromiseextendsOldPromise {
    constructor(executor) {
    // do whatever you want here, but must call super()console.log('hello, promise');

    super(executor); // call native Promise constructor
  }
};

Promise.resolve();

Source: Monkey-patch Promise constructor

Post a Comment for "Tracking/logging Promises"