Skip to content

Commit c7c7ef2

Browse files
gnofflubieowoce
andcommitted
[Flight Reply] retain listeners when resolving models with existing listeners
In #29201 a fix was made to ensure we don't "forget" about some listeners when handling cyclic chunks. In #29204 another fix was made for a special case when the chunk already has listeners before it first resolves. This implements the followup fix for Flight Reply which was originally missed in #29204 Co-Authored-by: Janka Uryga <[email protected]>
1 parent 0f58454 commit c7c7ef2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packages/react-server/src/ReactFlightReplyServer.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,23 @@ function wakeChunkIfInitialized<T>(
205205
case PENDING:
206206
case BLOCKED:
207207
case CYCLIC:
208-
chunk.value = resolveListeners;
209-
chunk.reason = rejectListeners;
208+
if (chunk.value) {
209+
for (let i = 0; i < resolveListeners.length; i++) {
210+
chunk.value.push(resolveListeners[i]);
211+
}
212+
} else {
213+
chunk.value = resolveListeners;
214+
}
215+
216+
if (chunk.reason) {
217+
if (rejectListeners) {
218+
for (let i = 0; i < rejectListeners.length; i++) {
219+
chunk.reason.push(rejectListeners[i]);
220+
}
221+
}
222+
} else {
223+
chunk.reason = rejectListeners;
224+
}
210225
break;
211226
case ERRORED:
212227
if (rejectListeners) {

0 commit comments

Comments
 (0)