diff --git a/packages/react-server/src/ReactFlightReplyServer.js b/packages/react-server/src/ReactFlightReplyServer.js index 1831a358576..4d5a6da8b8e 100644 --- a/packages/react-server/src/ReactFlightReplyServer.js +++ b/packages/react-server/src/ReactFlightReplyServer.js @@ -132,8 +132,10 @@ ReactPromise.prototype.then = function ( 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.')); }