-
Notifications
You must be signed in to change notification settings - Fork 50.2k
Open
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
React version:
19.0.3
Steps To Reproduce
- In
ReactFlightReplyServer.js, construct a chain ofReactPromiseinstances where each.valuepoints to the next, and the last one points back to the first (e.g.A -> B -> C -> A), creating a multi‑node cycle. - Trigger the cycle detection logic by resolving a chunk whose
valueis the head of this cycle and observing how thewhile (inspectedValue instanceof ReactPromise)loop behaves.
The current behavior
The cycle detection added in commit bd4289b only checks for a direct
self‑reference:
let cycleProtection = 0;
while (inspectedValue instanceof ReactPromise) {
cycleProtection++;
if (inspectedValue === chunk || cycleProtection > 1000) {
if (typeof reject === 'function') {
reject(new Error('Cannot have cyclic thenables.'));
}
}
}inspectedValue === chunk catches a simple self‑loop, but a longer cycle like A -> B -> C -> A will continue iterating until the cycleProtection counter hits the
The expected behavior
Any cyclic thenable chain, including multi‑node cycles (not just direct
self‑references), should be rejected as soon as a ReactPromise is encountered more than once in the traversal, rather than relying on the cycleProtection cap to eventually bail out.
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug