-
Notifications
You must be signed in to change notification settings - Fork 49.7k
[Flight] Insert an extra await node for awaiting on the promise returned by then callback #33713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| let firstFrame = 0; | ||
| while ( | ||
| fullStack.length > firstFrame && | ||
| fullStack[firstFrame][0] === 'Promise.then' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call raw .then() then that gets a stack frame that's not in user space which we need to ignore. The first frame after user space should be considered for the heuristic.
| ], | ||
| "start": 0, | ||
| "value": { | ||
| "value": undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little counter intuitive but the I/O that was awaited didn't have a value since that's the .then() call on delay() which resolves to undefined.
|
Comparing: 4aad5e4...18af1b8 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
When a
.then()callback returns another Promise, there's effectively another "await" on that Promise that happens in the internals but that was not modeled. In effect the Promise returned by.then()is blocked on both the original Promise AND the promise returned by the callback.This models that by cloning the original node and treat that as the await on the original Promise. Then we use the existing Node to await the new Promise but its "previous" points to the clone. That way we have a forked node that awaits both.