Break infinite loop that happens only in debug environments

Reviewed By: javache

Differential Revision: D4411870

fbshipit-source-id: 6b141e42206734368ed50f37c8e7df8e8fd006c0
This commit is contained in:
Max Sherman 2017-01-17 16:57:32 -08:00 committed by Facebook Github Bot
parent e93ccfd57a
commit a6844bdf75

View File

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