Skip to content

Commit fc5c53c

Browse files
sebmarkbageeps1lon
authored andcommitted
Add extra protection
1 parent b910fc1 commit fc5c53c

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
@@ -131,8 +131,10 @@ ReactPromise.prototype.then = function <T>(
131131
let inspectedValue = chunk.value;
132132
// Recursively check if the value is itself a ReactPromise and if so if it points
133133
// back to itself. This helps catch recursive thenables early error.
134+
let cycleProtection = 0;
134135
while (inspectedValue instanceof ReactPromise) {
135-
if (inspectedValue === chunk) {
136+
cycleProtection++;
137+
if (inspectedValue === chunk || cycleProtection > 1000) {
136138
if (typeof reject === 'function') {
137139
reject(new Error('Cannot have cyclic thenables.'));
138140
}

0 commit comments

Comments
 (0)