Skip to content

Conversation

@leeguooooo
Copy link

Summary

  • Track the thenable thrown by React.lazy with the same bookkeeping as use(), preventing short-lived promises from being missed.
  • Retry lazy initialization after instrumentation to resolve synchronously when possible.

How did you test this change?

  • yarn test ReactLazy-test.internal

Fixes #35399

@meta-cla meta-cla bot added the CLA Signed label Dec 29, 2025
@leeguooooo leeguooooo force-pushed the fix-35399-lazy-thenable-race branch from 3b3cfe6 to 46604ca Compare December 29, 2025 03:06
@leeguooooo leeguooooo marked this pull request as ready for review December 29, 2025 04:44
@ApsiV11
Copy link

ApsiV11 commented Jan 2, 2026

This PR seems to also fix useId causing hydration issues. At least vercel/next.js#84029 and #35210 would be fixed.

Copy link
Collaborator

@acdlite acdlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Great fix. Do you think you'd be able to write a regression test that reproduces the useId error you're referencing? (If not, I think it's fine to land as is.)

@react-sizebot
Copy link

react-sizebot commented Jan 14, 2026

Comparing: 4a3d993...5027732

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 +0.05% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.01% 608.03 kB 608.10 kB +0.02% 107.61 kB 107.63 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 = 667.26 kB 667.32 kB = 117.51 kB 117.52 kB
facebook-www/ReactDOM-prod.classic.js = 693.38 kB 693.44 kB = 122.00 kB 122.01 kB
facebook-www/ReactDOM-prod.modern.js = 683.76 kB 683.83 kB = 120.40 kB 120.41 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 5027732

Copy link
Collaborator

@acdlite acdlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually nvm I think we need to add a regression test before landing this

@eps1lon
Copy link
Collaborator

eps1lon commented Jan 14, 2026

The failing devtools test is also sus though it might just be a missing await and switch to async act.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: resolveLazy catching promises causes race condition with short-lived Suspense-wrapped components

5 participants