Skip to content

Commit a6844bd

Browse files
johnislarryfacebook-github-bot
authored andcommitted
Break infinite loop that happens only in debug environments
Reviewed By: javache Differential Revision: D4411870 fbshipit-source-id: 6b141e42206734368ed50f37c8e7df8e8fd006c0
1 parent e93ccfd commit a6844bd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Libraries/Utilities/defineLazyObjectProperty.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ function defineLazyObjectProperty<T>(
3535
// `setValue` which calls `Object.defineProperty` which somehow triggers
3636
// `getValue` again. Adding `valueSet` breaks this loop.
3737
if (!valueSet) {
38+
// Calling `get()` here can trigger an infinite loop if it fails to
39+
// remove the getter on the property, which can happen when executing
40+
// JS in a V8 context. `valueSet = true` will break this loop, and
41+
// sets the value of the property to undefined, until the code in `get()`
42+
// finishes, at which point the property is set to the correct value.
43+
valueSet = true;
3844
setValue(get());
3945
}
4046
return value;

0 commit comments

Comments
 (0)