Skip to content

Commit

Permalink
Revert "[Flight] Serialize deduped elements by direct reference even …
Browse files Browse the repository at this point in the history
…if they suspend (#28283)"

This reverts commit ba5e6a8.
  • Loading branch information
unstubbable committed Mar 21, 2024
1 parent d5cbcd6 commit 15fefa1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1334,16 +1334,12 @@ function renderModelDestructive(
// but that is able to reuse the same task if we're already in one but then that
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
const newId = outlineModel(request, (value: any));
return serializeByValueID(newId);
return serializeLazyID(newId);
} else {
// We've already emitted this as an outlined object, so we can refer to that by its
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
// elements might suspend so it might not have emitted yet even if we have the ID for
// it. However, this creates an extra wrapper when it's not needed. We should really
// detect whether this already was emitted and synchronously available. In that
// case we can refer to it synchronously and only make it lazy otherwise.
// We currently don't have a data structure that lets us see that though.
return serializeByValueID(existingId);
// existing ID. We use a lazy reference since, unlike plain objects, elements might
// suspend so it might not have emitted yet even if we have the ID for it.
return serializeLazyID(existingId);
}
} else {
// This is the first time we've seen this object. We may never see it again
Expand Down

0 comments on commit 15fefa1

Please sign in to comment.