Repository navigation
Conversation
Summary: A cyclic JavaScript value can leave prop conversion stuck while memory grows. Native debug builds now detect the cycle and throw a `JSError`, returning control to JavaScript instead of hanging. Release-build conversion is unchanged. **How the hang happens** 1. Fabric converts a component's raw props through `RawProps::toDynamic` and `jsi::dynamicFromValue`. 2. The converter walks objects with an explicit stack. A cycle keeps expanding the same path instead of finishing. 3. The call never returns, so the JavaScript thread remains stuck while the partial output and pending handles grow. **What changes** When `NDEBUG` is not defined, the converter uses Brent's algorithm to detect cycles without a visited set. Cyclic values throw, while acyclic values—including objects shared across paths—continue to convert normally. When `NDEBUG` is defined, all cycle-detection code is excluded: depth fields and arguments, ancestor storage, comparisons and updates. The release converter retains its original code and behavior, including the existing hang on cyclic values. This is a native-build guard, not the JavaScript `__DEV__` flag. Changelog: [General][Fixed] - Detect cyclic JavaScript values during debug-build conversion to folly::dynamic Reviewed By: javache Differential Revision: D132584875
|
@dalves has exported this pull request. If you are a Meta employee, you can view the originating Diff in D132584875. |
javache
approved these changes
Nov 25, 2026
javache
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
A cyclic JavaScript value can leave prop conversion stuck while memory grows. Native debug builds now detect the cycle and throw a
JSError, returning control to JavaScript instead of hanging. Release-build conversion is unchanged.How the hang happens
RawProps::toDynamicandjsi::dynamicFromValue.What changes
When
NDEBUGis not defined, the converter uses Brent's algorithm to detect cycles without a visited set. Cyclic values throw, while acyclic values—including objects shared across paths—continue to convert normally.When
NDEBUGis defined, all cycle-detection code is excluded: depth fields and arguments, ancestor storage, comparisons and updates. The release converter retains its original code and behavior, including the existing hang on cyclic values. This is a native-build guard, not the JavaScript__DEV__flag.Changelog:
[General][Fixed] - Detect cyclic JavaScript values during debug-build conversion to folly::dynamic
Reviewed By: javache
Differential Revision: D132584875