Skip to content

Conversation

@cvan20191
Copy link
Contributor

@cvan20191 cvan20191 commented Dec 16, 2025

Summary

This PR improves cyclic thenable detection in ReactFlightReplyServer.js. Fixes #35368.
The previous fix only detected direct self-references (inspectedValue === chunk) and relied on the cycleProtection counter to eventually bail out of longer cycles. This change keeps the existing MAX_THENABLE_CYCLE_DEPTH ($1000$) cycleProtection cap as a hard guardrail and adds a visited set so that we can detect self-cycles and multi-node cycles as soon as any ReactPromise is revisited and while still bounding the amount of work we do for deep acyclic chains via cycleProtection.

How did you test this change?

  • Ran the existing test suite for the server renderer:

    yarn test react-server
    yarn test --prod react-server
    yarn flow dom-node
    yarn linc

@meta-cla
Copy link

meta-cla bot commented Dec 16, 2025

Hi @cvan20191!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla
Copy link

meta-cla bot commented Dec 16, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Dec 16, 2025
@react-sizebot
Copy link

Comparing: 88ee1f5...50c5c98

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 = 608.16 kB 608.16 kB = 107.67 kB 107.67 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.39 kB 667.39 kB = 117.55 kB 117.55 kB
facebook-www/ReactDOM-prod.classic.js = 693.47 kB 693.47 kB = 122.05 kB 122.05 kB
facebook-www/ReactDOM-prod.modern.js = 683.89 kB 683.89 kB = 120.43 kB 120.43 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 50c5c98

Copy link
Collaborator

@unstubbable unstubbable left a comment

Choose a reason for hiding this comment

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

Thank you.

@unstubbable unstubbable merged commit b731fe2 into facebook:main Dec 17, 2025
239 checks passed
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.

Improve cyclic thenable detection in ReactFlightReplyServer

3 participants