Unhandled rejections should be logged whenever there's an unhandled rejection, so 1 and 3 are bugs because you don't have any handlers for the rejection registered by the "start of the second turn".
when does bluebird log unhandled rejections?
Domanda
I'm having trouble understanding when bluebird will log an unhandled rejection versus dropping it. I guess this has something to do with what the documentation calls "the second turn" but I'm not clear what that means.
Promise.reject(new Error("oops"))
-> no log
Promise.reject(new Error("oops")).then(function() {})
-> stack trace logged
Promise.method(function() { throw new Error("oops"); })()
-> no log
Promise.method(function() { throw new Error("oops"); })().then(function() {})
-> stack trace logged
Promise.promisify(function(k) { k(new Error("oops"), null); })()
-> stack trace logged
I am in the middle of converting some code to bluebird promises and I am getting rejections dropped all over the place. (Okay, first it was #100, I'm an idiot.) I guess I will use .promisify rather than .method to get past my current silent failures but I'm frightened that there might be other circumstances where I'll miss a thrown error.
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow