Conversation
8e61701 to
5d3341b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6049 +/- ##
==========================================
+ Coverage 70.34% 70.37% +0.02%
==========================================
Files 408 408
Lines 108646 108852 +206
Branches 17991 18007 +16
==========================================
+ Hits 76431 76604 +173
- Misses 21412 21440 +28
- Partials 10803 10808 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Initial review pass done. I'm going to want to check this out locally at do a thorough test on it tho... which I can't do at the moment as I'm in the middle of another investigation. Will come back to this and test locally as soon as I'm able |
450ccdf to
a314084
Compare
|
Overall the change is fine. I do worry about the possibility of this breaking someone tho. Specifically, it can change behavior in an existing worker. Consider: addEventListener('unhandledrejection', () => {
console.log('does not fire');
});
export default {
async fetch() {
Promise.reject('boom');
await Promise.resolve();
return new Response('ok');
}
}In the current code, the If we change the awaited promise to await actual i/o, the handler DOES fire. addEventListener('unhandledrejection', () => {
console.log('fires');
});
export default {
async fetch() {
Promise.reject('boom');
await scheduler.resolve();
return new Response('ok');
}
}If a worker has come to rely on the current behavior (unlikely but possible) then their worker could end up broken. Given that, I think to be completely safe this might need a compat flag... but I'm also open to being convinced otherwise. |
|
I don't see any problem with being a little bit more cautious and surround this change with a compatibility flag. @jasnell |
Merging this PR will degrade performance by 10.92%
Performance Changes
Comparing Footnotes
|
jasnell
left a comment
There was a problem hiding this comment.
I'm not super familiar with the microtask checkpoint callback being used here so while the changes LGTM, I'd like for you to get either @erikcorry or @dcarney-cf review just to make sure there's not something lurking there that we're missing.
Fixes #6020
This change fixes premature unhandledrejection events by running unhandled‑rejection processing only after V8 finishes a microtask checkpoint. We now schedule the check via V8's microtask‑completed callback and request an extra checkpoint so any handlers queued by unhandledrejection listeners run promptly. We also keep promise/value references strong until the event is dispatched, then downgrade to weak to avoid leaks.