Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/react-server/src/ReactFlightReplyServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
}
Expand Down
Loading