Skip to content

Commit 631bb04

Browse files
committed
Serialize deduped elements by direct reference even if they suspend
1 parent d3def47 commit 631bb04

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,12 +1192,16 @@ function renderModelDestructive(
11921192
// but that is able to reuse the same task if we're already in one but then that
11931193
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
11941194
const newId = outlineModel(request, (value: any));
1195-
return serializeLazyID(newId);
1195+
return serializeByValueID(newId);
11961196
} else {
11971197
// We've already emitted this as an outlined object, so we can refer to that by its
1198-
// existing ID. We use a lazy reference since, unlike plain objects, elements might
1199-
// suspend so it might not have emitted yet even if we have the ID for it.
1200-
return serializeLazyID(existingId);
1198+
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
1199+
// elements might suspend so it might not have emitted yet even if we have the ID for
1200+
// it. However, this creates an extra wrapper when it's not needed. We should really
1201+
// detect whether this already was emitted and synchronously available. In that
1202+
// case we can refer to it synchronously and only make it lazy otherwise.
1203+
// We currently don't have a data structure that lets us see that though.
1204+
return serializeByValueID(existingId);
12011205
}
12021206
} else {
12031207
// This is the first time we've seen this object. We may never see it again

0 commit comments

Comments
 (0)