Skip to content

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Jul 18, 2025

Summary

As indicated by the previous issue comment #27731 (comment), it looks like legacy "throw thenable"-based suspense implementation (used by React.lazy) causes an issue with React.use based suspense implementation, which relies on thenableState hook state tracking.

The PR fixes the issue by avoiding getThenableStateAfterSuspending when legacy "throw thenable" style suspension happened. I tried a different approach such as resetting task.thenableState = null during renderLazyComponent, but it broke one test case useActionState can return binary state during MPA form submission in packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js.

(By no means, I'm confident with the change, but I thought poking around the code provides better insight for short term workaround. See #33937 (comment). I'd appreciate any help on the issue.)

How did you test this change?

I added a test case in packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js based on the reproduction of the issue (and also #33938).

@meta-cla meta-cla bot added the CLA Signed label Jul 18, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review July 18, 2025 08:53
@himself65
Copy link
Contributor

/cc @acdlite

@gaearon
Copy link
Collaborator

gaearon commented Jul 22, 2025

cc @eps1lon

@react-sizebot
Copy link

Comparing: dffacc7...dc09e25

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.11% 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.05% 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.11 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.production.js +0.42% 135.26 kB 135.83 kB +0.18% 23.93 kB 23.97 kB
oss-stable/react-server/cjs/react-server.production.js +0.42% 135.26 kB 135.83 kB +0.18% 23.93 kB 23.97 kB
oss-experimental/react-server/cjs/react-server.production.js +0.39% 153.01 kB 153.61 kB +0.15% 26.57 kB 26.61 kB
oss-stable-semver/react-server/cjs/react-server.development.js +0.31% 195.32 kB 195.93 kB +0.14% 34.57 kB 34.62 kB
oss-stable/react-server/cjs/react-server.development.js +0.31% 195.32 kB 195.93 kB +0.14% 34.57 kB 34.62 kB
oss-experimental/react-server/cjs/react-server.development.js +0.28% 214.87 kB 215.47 kB +0.07% 37.26 kB 37.29 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.23% 233.01 kB 233.55 kB +0.11% 42.27 kB 42.32 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.23% 233.04 kB 233.57 kB +0.10% 42.30 kB 42.34 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.js +0.22% 237.62 kB 238.16 kB +0.08% 44.09 kB 44.13 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.js +0.22% 237.65 kB 238.18 kB +0.08% 44.12 kB 44.16 kB
oss-experimental/react-markup/cjs/react-markup.production.js +0.22% 250.47 kB 251.02 kB +0.08% 46.00 kB 46.04 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.js +0.22% 239.92 kB 240.45 kB +0.08% 43.81 kB 43.84 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.js +0.22% 239.99 kB 240.53 kB +0.08% 43.84 kB 43.87 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.21% 263.10 kB 263.66 kB +0.08% 46.73 kB 46.77 kB
facebook-www/ReactDOMServer-prod.modern.js +0.21% 251.81 kB 252.35 kB +0.10% 45.08 kB 45.12 kB
facebook-www/ReactDOMServer-prod.classic.js +0.21% 254.15 kB 254.68 kB +0.10% 45.42 kB 45.46 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.js +0.21% 256.01 kB 256.55 kB +0.08% 46.37 kB 46.41 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.js +0.21% 256.09 kB 256.62 kB +0.08% 46.40 kB 46.44 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.js +0.21% 268.64 kB 269.20 kB +0.07% 48.89 kB 48.92 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js +0.21% 260.89 kB 261.43 kB +0.06% 47.74 kB 47.77 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.production.js +0.20% 261.33 kB 261.86 kB +0.07% 48.41 kB 48.45 kB
oss-stable/react-dom/cjs/react-dom-server.edge.production.js +0.20% 261.40 kB 261.94 kB +0.07% 48.44 kB 48.48 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.js +0.20% 261.57 kB 262.10 kB +0.07% 46.87 kB 46.90 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.js +0.20% 261.64 kB 262.18 kB +0.07% 46.89 kB 46.92 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +0.20% 274.47 kB 275.03 kB +0.06% 49.24 kB 49.27 kB

Generated by 🚫 dangerJS against dc09e25

Copy link
Collaborator

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Changes makes sense to me since the added check matches the one we do earlier before we call getSuspendedThenable. Thank you!

@eps1lon eps1lon merged commit cc01584 into facebook:main Jul 28, 2025
244 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 28, 2025
@sebmarkbage
Copy link
Collaborator

It's unfortunate because we need the thenable state for other debug info. However, there's a general problem with "throw a Promise" and debugging that leads us to wanting to deprecate the whole feature anyway.

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: React.use inside React.lazy-ed component returns other React.use value on SSR
6 participants