Skip to content

Commit bd4289b

Browse files
sebmarkbageeps1lon
authored andcommitted
Add extra protection
1 parent 61c95d0 commit bd4289b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/react-server/src/ReactFlightReplyServer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ ReactPromise.prototype.then = function <T>(
135135
let inspectedValue = chunk.value;
136136
// Recursively check if the value is itself a ReactPromise and if so if it points
137137
// back to itself. This helps catch recursive thenables early error.
138+
let cycleProtection = 0;
138139
while (inspectedValue instanceof ReactPromise) {
139-
if (inspectedValue === chunk) {
140+
cycleProtection++;
141+
if (inspectedValue === chunk || cycleProtection > 1000) {
140142
if (typeof reject === 'function') {
141143
reject(new Error('Cannot have cyclic thenables.'));
142144
}

0 commit comments

Comments
 (0)