@@ -5829,6 +5829,7 @@ export function attach(
58295829 }
58305830
58315831 const foundIOEntries: Set<ReactIOInfo> = new Set();
5832+ const streamEntries: Map<Promise<mixed>, ReactAsyncInfo> = new Map();
58325833 const result: Array<SerializedAsyncInfo> = [];
58335834 for (let i = 0; i < suspendedBy.length; i++) {
58345835 const asyncInfo = suspendedBy[i];
@@ -5839,8 +5840,33 @@ export function attach(
58395840 continue;
58405841 }
58415842 foundIOEntries.add(ioInfo);
5842- result.push(serializeAsyncInfo(asyncInfo, devtoolsInstance, hooks));
5843+ if (ioInfo.name === 'RSC stream' && ioInfo.value != null) {
5844+ const streamPromise = ioInfo.value;
5845+ // Special case RSC stream entries to pick the last entry keyed by the stream.
5846+ const existingEntry = streamEntries.get(streamPromise);
5847+ if (existingEntry === undefined) {
5848+ streamEntries.set(streamPromise, asyncInfo);
5849+ } else {
5850+ const existingIO = existingEntry.awaited;
5851+ if (
5852+ ioInfo !== existingIO &&
5853+ ((ioInfo.byteSize !== undefined &&
5854+ existingIO.byteSize !== undefined &&
5855+ ioInfo.byteSize > existingIO.byteSize) ||
5856+ ioInfo.end > existingIO.end)
5857+ ) {
5858+ // The new entry is later in the stream that the old entry. Replace it.
5859+ streamEntries.set(streamPromise, asyncInfo);
5860+ }
5861+ }
5862+ } else {
5863+ result.push(serializeAsyncInfo(asyncInfo, devtoolsInstance, hooks));
5864+ }
58435865 }
5866+ // Add any deduped stream entries.
5867+ streamEntries.forEach(asyncInfo => {
5868+ result.push(serializeAsyncInfo(asyncInfo, devtoolsInstance, hooks));
5869+ });
58445870 return result;
58455871 }
58465872
0 commit comments