mirror of
https://github.com/facebook/react.git
synced 2026-02-22 03:42:05 +00:00
committed by
GitHub
parent
80cb7a9925
commit
b45bb335db
@@ -132,8 +132,10 @@ ReactPromise.prototype.then = function <T>(
|
||||
let inspectedValue = chunk.value;
|
||||
// Recursively check if the value is itself a ReactPromise and if so if it points
|
||||
// back to itself. This helps catch recursive thenables early error.
|
||||
let cycleProtection = 0;
|
||||
while (inspectedValue instanceof ReactPromise) {
|
||||
if (inspectedValue === chunk) {
|
||||
cycleProtection++;
|
||||
if (inspectedValue === chunk || cycleProtection > 1000) {
|
||||
if (typeof reject === 'function') {
|
||||
reject(new Error('Cannot have cyclic thenables.'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user