From a6844bdf7589b38297328e69f61e2986a129ab30 Mon Sep 17 00:00:00 2001 From: Max Sherman Date: Tue, 17 Jan 2017 16:57:32 -0800 Subject: [PATCH] Break infinite loop that happens only in debug environments Reviewed By: javache Differential Revision: D4411870 fbshipit-source-id: 6b141e42206734368ed50f37c8e7df8e8fd006c0 --- Libraries/Utilities/defineLazyObjectProperty.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Libraries/Utilities/defineLazyObjectProperty.js b/Libraries/Utilities/defineLazyObjectProperty.js index 7013ab6cb5a..25c5e0057b3 100644 --- a/Libraries/Utilities/defineLazyObjectProperty.js +++ b/Libraries/Utilities/defineLazyObjectProperty.js @@ -35,6 +35,12 @@ function defineLazyObjectProperty( // `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;