Skip to content

Conversation

@parisaghm
Copy link

Summary

This change improves cyclic thenable detection in ReactFlightReplyServer by tracking visited ReactPromise instances during traversal.

Previously, the logic only detected direct self-references and relied on a fixed iteration limit to bail out. This meant multi-node cycles (e.g. A → B → C → A or A → B → C → B) were not detected immediately.

The updated implementation introduces a Set to record visited promises and rejects as soon as a previously seen ReactPromise is encountered, ensuring correct and early detection of all cyclic cases. A safety iteration counter is kept as a secondary defense, although it should not be reached under normal conditions.

Fixes #35368

How did you test this change?

  • Manually reproduced the issue by constructing chains of ReactPromise instances forming different cycle patterns:
    • Direct self-reference (A → A)
    • Multi-node cycles (A → B → C → A)
    • Non-head cycles (A → B → C → B)
  • Verified that the traversal now rejects immediately upon revisiting a previously seen ReactPromise, instead of iterating until the iteration limit.
  • Confirmed that non-cyclic chains resolve normally once a non-ReactPromise or non-INITIALIZED value is reached.

Not run via full test suite (change is localized and verified through targeted reproduction).

@meta-cla
Copy link

meta-cla bot commented Dec 16, 2025

Hi @parisaghm!

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
@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!

@unstubbable
Copy link
Collaborator

resolved in #35369

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

2 participants