mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
Break infinite loop that happens only in debug environments
Reviewed By: javache Differential Revision: D4411870 fbshipit-source-id: 6b141e42206734368ed50f37c8e7df8e8fd006c0
This commit is contained in:
parent
e93ccfd57a
commit
a6844bdf75
@ -35,6 +35,12 @@ function defineLazyObjectProperty<T>(
|
||||
// `setValue` which calls `Object.defineProperty` which somehow triggers
|
||||
// `getValue` again. Adding `valueSet` breaks this loop.
|
||||
if (!valueSet) {
|
||||
// Calling `get()` here can trigger an infinite loop if it fails to
|
||||
// remove the getter on the property, which can happen when executing
|
||||
// JS in a V8 context. `valueSet = true` will break this loop, and
|
||||
// sets the value of the property to undefined, until the code in `get()`
|
||||
// finishes, at which point the property is set to the correct value.
|
||||
valueSet = true;
|
||||
setValue(get());
|
||||
}
|
||||
return value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user