Fix unhandled promise rejection tracker, again#1049
Conversation
|
@ChALkeR mind taking a look? |
|
#1038 (comment) now works #1038 (comment) doesn't
|
|
Simplified testcase: const promise = Promise.reject('reject')
const error = await Promise.resolve().then(() => promise).catch(e => e)
console.log('Got this error:', error)This still crashes the process |
|
Actually a simpler one: const promise = Promise.reject('reject')
print(promise) |
|
Back to the drawing board :-) |
Node.js disagrees on that and treats that as unhandled (unlike the other examples above) |
|
Latest commit doesn't catch this anymore: async function foo() {
throw new Error('failed')
}
foo()
const setTimeout = globalThis.setTimeout || os.setTimeout
setTimeout(() => console.log('done'), 1000) |
|
You're right... |
51b4dda to
1c395ba
Compare
|
Removed the latest commit. I need to see how to tell those 2 cases appart. |
|
That depends on the event loop In Node.js:
|
1c395ba to
0452dfe
Compare
Delay checking for unhandled rejections so we can make sure to check after other promise jobs have ran.
0452dfe to
8c43cf9
Compare
|
@bnoordhuis PTAL again, I changed the approach. The way it currently works |
|
@ChALkeR do your worst :-) |
bnoordhuis
left a comment
There was a problem hiding this comment.
Checking for specific callbacks seems a little fragile but I don't have a better suggestion.
Mark a rejected promise as handled if we are passing it as as a resolution up a promise chain.