Skip to content

Conversation

@gnoff
Copy link
Collaborator

@gnoff gnoff commented Jan 16, 2026

When a lazy element or component is initialized a thenable is returned which was only be conditionally instrumented in dev when asyncDebugInfo was enabled. When instrumented these thenables can be used in conjunction with the SuspendOnImmediate optimization where if a thenable resolves before the stack unwinds we can continue rendering from the last suspended fiber. Without this change a recent fix to the useId implementation cannot be easily tested in production because this optimization pathway isn't available to regular React.lazy thenables. To land the prior PR I changed the thenables to a custom type so I could instrument manually in the test. WIth this change we can just use a regular Promise since ReactLazy will instrument in all environments/flags now

@gnoff gnoff requested a review from sebmarkbage January 16, 2026 00:51
@meta-cla meta-cla bot added the CLA Signed label Jan 16, 2026
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jan 16, 2026
@react-sizebot
Copy link

react-sizebot commented Jan 16, 2026

Comparing: 4cf9063...a17b694

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.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 608.20 kB 608.03 kB = 107.66 kB 107.62 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 670.67 kB 667.26 kB = 118.08 kB 117.51 kB
facebook-www/ReactDOM-prod.classic.js = 693.57 kB 693.38 kB = 122.05 kB 122.01 kB
facebook-www/ReactDOM-prod.modern.js = 683.95 kB 683.76 kB = 120.44 kB 120.40 kB
oss-stable-semver/react/cjs/react.react-server.production.js +2.21% 13.51 kB 13.81 kB +0.67% 3.71 kB 3.74 kB
oss-stable/react/cjs/react.react-server.production.js +2.21% 13.54 kB 13.83 kB +0.67% 3.74 kB 3.77 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/cjs/react.react-server.production.js +2.21% 13.51 kB 13.81 kB +0.67% 3.71 kB 3.74 kB
oss-stable/react/cjs/react.react-server.production.js +2.21% 13.54 kB 13.83 kB +0.67% 3.74 kB 3.77 kB
oss-stable-semver/react/cjs/react.production.js +1.69% 17.74 kB 18.04 kB +0.63% 4.57 kB 4.60 kB
oss-stable/react/cjs/react.production.js +1.68% 17.77 kB 18.07 kB +0.63% 4.60 kB 4.63 kB
oss-experimental/react/cjs/react.react-server.production.js +1.56% 19.11 kB 19.41 kB +0.52% 5.00 kB 5.03 kB
facebook-react-native/react/cjs/React-prod.js +1.56% 19.23 kB 19.53 kB +0.59% 4.95 kB 4.98 kB
oss-experimental/react/cjs/react.production.js +1.54% 19.46 kB 19.76 kB +0.59% 4.92 kB 4.95 kB
facebook-react-native/react/cjs/React-profiling.js +1.52% 19.66 kB 19.96 kB +0.58% 5.03 kB 5.06 kB
facebook-www/React-prod.modern.js +1.48% 20.14 kB 20.44 kB +0.54% 5.17 kB 5.20 kB
facebook-www/React-prod.classic.js +1.48% 20.14 kB 20.44 kB +0.54% 5.17 kB 5.20 kB
facebook-www/React-profiling.modern.js +1.45% 20.57 kB 20.87 kB +0.53% 5.25 kB 5.28 kB
facebook-www/React-profiling.classic.js +1.45% 20.57 kB 20.87 kB +0.55% 5.25 kB 5.28 kB
facebook-react-native/react/cjs/React-dev.js +0.61% 52.61 kB 52.93 kB +0.31% 11.61 kB 11.64 kB
oss-experimental/react-art/cjs/react-art.production.js = 358.53 kB 357.47 kB = 60.45 kB 60.23 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js = 1,262.67 kB 1,257.62 kB = 209.85 kB 208.90 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js = 1,262.67 kB 1,257.62 kB = 210.64 kB 209.73 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js = 1,246.12 kB 1,241.07 kB = 206.98 kB 206.04 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js = 685.08 kB 681.67 kB = 121.62 kB 121.07 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 670.67 kB 667.26 kB = 118.08 kB 117.51 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js = 862.37 kB 857.88 kB = 134.30 kB 133.50 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js = 749.95 kB 745.88 kB = 129.64 kB 128.84 kB
oss-experimental/react-art/cjs/react-art.development.js = 733.87 kB 729.74 kB = 115.46 kB 114.68 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js = 491.61 kB 488.70 kB = 78.19 kB 77.71 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js = 567.78 kB 564.15 kB = 88.42 kB 87.75 kB

Generated by 🚫 dangerJS against a17b694

@gnoff gnoff force-pushed the jstory/instrument-lazy-thenable-always branch 2 times, most recently from 3e36142 to ea92656 Compare January 16, 2026 01:28
When a lazy element or component is initialized a thenable is returned which was only be conditionally instrumented in dev when asyncDebugInfo was enabled. When instrumented these thenables can be used in conjunction with the SuspendOnImmediate optimization where if a thenable resolves before the stack unwinds we can continue rendering from the last suspended fiber. Without this change a recent fix to the useId implementation cannot be easily tested in production because this optimization pathway isn't available to regular React.lazy thenables. I could update the test to use a custom thenable but since this optimization is probably worthwhile anyway I am adding the instrumentation to all React.lazy.
@gnoff gnoff force-pushed the jstory/instrument-lazy-thenable-always branch from ea92656 to a17b694 Compare January 16, 2026 02:57
@gnoff gnoff merged commit db71391 into facebook:main Jan 16, 2026
234 checks passed
@gnoff gnoff deleted the jstory/instrument-lazy-thenable-always branch January 16, 2026 03:05
github-actions bot pushed a commit that referenced this pull request Jan 16, 2026
When a lazy element or component is initialized a thenable is returned
which was only be conditionally instrumented in dev when asyncDebugInfo
was enabled. When instrumented these thenables can be used in
conjunction with the SuspendOnImmediate optimization where if a thenable
resolves before the stack unwinds we can continue rendering from the
last suspended fiber. Without this change a recent fix to the useId
implementation cannot be easily tested in production because this
optimization pathway isn't available to regular React.lazy thenables. To
land the prior PR I changed the thenables to a custom type so I could
instrument manually in the test. WIth this change we can just use a
regular Promise since ReactLazy will instrument in all
environments/flags now

DiffTrain build for [db71391](db71391)
github-actions bot pushed a commit that referenced this pull request Jan 16, 2026
When a lazy element or component is initialized a thenable is returned
which was only be conditionally instrumented in dev when asyncDebugInfo
was enabled. When instrumented these thenables can be used in
conjunction with the SuspendOnImmediate optimization where if a thenable
resolves before the stack unwinds we can continue rendering from the
last suspended fiber. Without this change a recent fix to the useId
implementation cannot be easily tested in production because this
optimization pathway isn't available to regular React.lazy thenables. To
land the prior PR I changed the thenables to a custom type so I could
instrument manually in the test. WIth this change we can just use a
regular Promise since ReactLazy will instrument in all
environments/flags now

DiffTrain build for [db71391](db71391)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Jan 18, 2026
…ok#35521)

When a lazy element or component is initialized a thenable is returned
which was only be conditionally instrumented in dev when asyncDebugInfo
was enabled. When instrumented these thenables can be used in
conjunction with the SuspendOnImmediate optimization where if a thenable
resolves before the stack unwinds we can continue rendering from the
last suspended fiber. Without this change a recent fix to the useId
implementation cannot be easily tested in production because this
optimization pathway isn't available to regular React.lazy thenables. To
land the prior PR I changed the thenables to a custom type so I could
instrument manually in the test. WIth this change we can just use a
regular Promise since ReactLazy will instrument in all
environments/flags now

DiffTrain build for [db71391](facebook@db71391)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Jan 18, 2026
…ok#35521)

When a lazy element or component is initialized a thenable is returned
which was only be conditionally instrumented in dev when asyncDebugInfo
was enabled. When instrumented these thenables can be used in
conjunction with the SuspendOnImmediate optimization where if a thenable
resolves before the stack unwinds we can continue rendering from the
last suspended fiber. Without this change a recent fix to the useId
implementation cannot be easily tested in production because this
optimization pathway isn't available to regular React.lazy thenables. To
land the prior PR I changed the thenables to a custom type so I could
instrument manually in the test. WIth this change we can just use a
regular Promise since ReactLazy will instrument in all
environments/flags now

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