@samitouri / QOS-React-2 / commits / 8ba3501cd9

[Flight] Don't dedupe references to deferred objects (#33741)

If we're about to defer an object, then we shouldn't store a reference to it because then we can end up deduping by referring to the deferred string. If in a different context, we should still be able to emit the object.

Sebastian Markbåge committed Jul 8, 2025 at 21:47 UTC 8ba3501cd9c982676fab35f1c8092302060d728c
1 file changed +6
packages/react-server/src/ReactFlightServer.js
+6
@@ -4345,6 +4345,12 @@ function renderDebugModel(
4345 if (parentReference !== undefined) {
4346 // If the parent has a reference, we can refer to this object indirectly
4347 // through the property name inside that parent.
4348 + if (counter.objectLimit <= 0 && !doNotLimit.has(value)) {
4349 + // If we are going to defer this, don't dedupe it since then we'd dedupe it to be
4350 + // deferred in future reference.
4351 + return serializeDeferredObject(request, value);
4352 + }
4353 +
4354 let propertyName = parentPropertyName;
4355 if (isArray(parent) && parent[0] === REACT_ELEMENT_TYPE) {
4356 // For elements, we've converted it to an array but we'll have converted