First Update:
I first thought .catch( callback)
after 'main' would return a new, pending promise of the extended Promise class, but this is incorrect - calling an async function returns a Promise
promise.
Cutting the code down further, to only produce a pending promise:
class CancellablePromise extends Promise {
constructor(executor) {
console.log("CancellablePromise::constructor");
super(executor);
}
}
async function test() {
await new CancellablePromise( ()=>null);
}
test();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…