Permalink
Browse files

Break infinite loop that happens only in debug environments

Reviewed By: javache

Differential Revision: D4411870

fbshipit-source-id: 6b141e42206734368ed50f37c8e7df8e8fd006c0
  • Loading branch information...
johnislarry authored and facebook-github-bot committed Jan 18, 2017
1 parent e93ccfd commit a6844bdf7589b38297328e69f61e2986a129ab30
Showing with 6 additions and 0 deletions.
  1. +6 −0 Libraries/Utilities/defineLazyObjectProperty.js
@@ -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;

0 comments on commit a6844bd

Please sign in to comment.