Monday 10 April 2017

Does Node.js have a process.pid equivalent to identify the current promise?

Debugging promises in Node can be difficult, requiring wrapping promise code. One utility that would help would something like:

node.util.promiseId() : return an id for the for current promise being executed.

So that I could:

function bar() {
    console.log('working on promise', node.util.promiseId());

function foo(result) {
    // analyze results in complicated way.
    bar();
    ...
}

fetch().then(foo)...

Is there anything close for ES6 promises?



via Charles Merriam

No comments:

Post a Comment