With JavaScript promises, in its ‘resolved handler’ how to find (if possible at all) where this particular promise was created?
E.g. in this situation, with this code (with async/await there seems to be no difference) when the code execution is stopped on the debugger
statement, how to see where the corresponding promise was created:
'use strict';
const promise = getPromise();
handleResolution(promise);
function handleResolution(promiseArg) {
promiseArg
.then((resolution) => {
debugger;
console.log(`resolved with: ${ resolution }`);
});
}
function getPromise() {
return new Promise((resolve) => {
resolve('in getPromise()');
});
}
Hardly the call stack can be used here, because it’s obvious that the call stack where a particular asynchronous call was done is long gone.
Is there something like a way to see a ‘promise chain’ sort of?
The question is about JS in general, not necessarily Node.js, Chrome dev tools etc. It just happened that I used this stack for this example.