Skip to content

Conversation

@sebmarkbage
Copy link
Collaborator

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.

@sebmarkbage sebmarkbage requested a review from eps1lon July 6, 2025 19:26
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jul 6, 2025
let firstFrame = 0;
while (
fullStack.length > firstFrame &&
fullStack[firstFrame][0] === 'Promise.then'
Copy link
Collaborator Author

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,
Copy link
Collaborator Author

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.

@react-sizebot
Copy link

Comparing: 4aad5e4...18af1b8

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB +0.05% 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.50 kB 530.50 kB = 93.66 kB 93.66 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 655.04 kB 655.04 kB = 115.35 kB 115.35 kB
facebook-www/ReactDOM-prod.classic.js = 675.12 kB 675.12 kB = 118.77 kB 118.77 kB
facebook-www/ReactDOM-prod.modern.js = 665.54 kB 665.54 kB = 117.13 kB 117.13 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.46% 194.47 kB 195.36 kB +0.48% 35.91 kB 36.08 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +0.45% 200.44 kB 201.33 kB +0.42% 36.60 kB 36.75 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.43% 207.21 kB 208.11 kB +0.39% 37.69 kB 37.84 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.43% 208.36 kB 209.26 kB +0.39% 38.00 kB 38.14 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.43% 208.42 kB 209.31 kB +0.39% 38.01 kB 38.16 kB

Generated by 🚫 dangerJS against 18af1b8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants