Skip to content

[Flight] Skip the stack frame of built-in wrappers that create or await Promises #33798

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

Merged
merged 2 commits into from
Jul 16, 2025

Conversation

sebmarkbage
Copy link
Collaborator

We already do this with "new Promise" and "Promise.then". There are also many helpers that both create promises and awaits other promises inside of it like Promise.all.

The way this is filtered is different from just filtering out all anonymous stacks since they're used to determine where the boundary is between ignore listed and user space.

Ideally we'd cover more wrappers that are internal to Promise libraries.

@sebmarkbage sebmarkbage requested a review from eps1lon July 16, 2025 17:54
@meta-cla meta-cla bot added the CLA Signed label Jul 16, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jul 16, 2025
0,
0,
0,
],
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 on the stack of where the thing happens. Since this implementation choses to include anonymous locations, it'll also have this on the stack. However it will not have the "new Promise" on the top of the stack.

@react-sizebot
Copy link

react-sizebot commented Jul 16, 2025

Comparing: 9fec565...534b056

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.16% 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.70 kB 530.70 kB = 93.70 kB 93.70 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 655.25 kB 655.25 kB = 115.40 kB 115.40 kB
facebook-www/ReactDOM-prod.classic.js = 675.13 kB 675.13 kB = 118.75 kB 118.75 kB
facebook-www/ReactDOM-prod.modern.js = 665.56 kB 665.56 kB = 117.11 kB 117.12 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-server/cjs/react-server-flight.production.js +0.85% 61.91 kB 62.44 kB +1.09% 12.43 kB 12.56 kB
oss-stable/react-server/cjs/react-server-flight.production.js +0.85% 61.91 kB 62.44 kB +1.09% 12.43 kB 12.56 kB
oss-experimental/react-server/cjs/react-server-flight.production.js +0.78% 67.74 kB 68.27 kB +1.03% 13.32 kB 13.46 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.66% 204.00 kB 205.35 kB +0.52% 37.31 kB 37.50 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-server.node.development.js +0.64% 210.50 kB 211.85 kB +0.50% 37.99 kB 38.18 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.62% 217.23 kB 218.59 kB +0.49% 39.13 kB 39.32 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.62% 218.39 kB 219.74 kB +0.50% 39.42 kB 39.62 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.62% 218.44 kB 219.79 kB +0.49% 39.43 kB 39.62 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.43% 132.14 kB 132.71 kB +0.51% 23.70 kB 23.82 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.43% 132.14 kB 132.71 kB +0.51% 23.70 kB 23.82 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.40% 141.32 kB 141.89 kB +0.46% 25.25 kB 25.37 kB

Generated by 🚫 dangerJS against 534b056

"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 now using the await inside the Promise.all and its "value" is the return value of the delay (undefined). Previously, the Promise.all call was skipped and it used the await of the Promise.all instead. So we get the value of the last resolved I/O of the set, which is also the stack that we get.

The tradeoff is that we don't see all the values of a set if multiple things are awaited but that's not what we're modeling in this entry anyway since it won't have the time spans and stacks for earlier resolutions anyway.

@sebmarkbage sebmarkbage force-pushed the promisespecialcases branch from d7abbb2 to 534b056 Compare July 16, 2025 17:58
@sebmarkbage sebmarkbage merged commit da7487b into facebook:main Jul 16, 2025
242 checks passed
github-actions bot pushed a commit to code/lib-react that referenced this pull request Jul 20, 2025
…it Promises (facebook#33798)

We already do this with `"new Promise"` and `"Promise.then"`. There are
also many helpers that both create promises and awaits other promises
inside of it like `Promise.all`.

The way this is filtered is different from just filtering out all
anonymous stacks since they're used to determine where the boundary is
between ignore listed and user space.

Ideally we'd cover more wrappers that are internal to Promise libraries.

DiffTrain build for [da7487b](facebook@da7487b)
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.

3 participants