Chrome's break-on-exception doesn't always break when exceptions are thrown in a promise callback.
it('confuses me', () => {
let start = new Promise(r => setTimeout(r, 10))
let forked = delay.then(() => { throw "huh" })
return wantBroken ? forked : start
})
Returning start works fine, but returning forked won't break (but it does print to the console). If you add a catch block to runTest, it catches the error, so it's not like the promise is just swallowing it.
I've also noticed that bluebird promises don't have this issue. The problem with bluebird is that stack traces are very wrong (even with longStackTrace on).
I think the ideal would be to figure out how bluebird does it, and replicate.
Chrome's break-on-exception doesn't always break when exceptions are thrown in a promise callback.
Returning
startworks fine, but returningforkedwon't break (but it does print to the console). If you add acatchblock torunTest, it catches the error, so it's not like the promise is just swallowing it.I've also noticed that bluebird promises don't have this issue. The problem with bluebird is that stack traces are very wrong (even with longStackTrace on).
I think the ideal would be to figure out how bluebird does it, and replicate.