Skip to content

Commit

Permalink
[Flight Reply] retain listeners when resolving models with existing l…
Browse files Browse the repository at this point in the history
…isteners

In facebook#29201 a fix was made to ensure we don't "forget" about some listeners when handling cyclic chunks.
In facebook#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 facebook#29204

Co-Authored-by: Janka Uryga <lolzatu2@gmail.com>
  • Loading branch information
gnoff and lubieowoce committed May 21, 2024
1 parent 0f58454 commit c7c7ef2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/react-server/src/ReactFlightReplyServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,23 @@ function wakeChunkIfInitialized<T>(
case PENDING:
case BLOCKED:
case CYCLIC:
chunk.value = resolveListeners;
chunk.reason = rejectListeners;
if (chunk.value) {
for (let i = 0; i < resolveListeners.length; i++) {
chunk.value.push(resolveListeners[i]);
}
} else {
chunk.value = resolveListeners;
}

if (chunk.reason) {
if (rejectListeners) {
for (let i = 0; i < rejectListeners.length; i++) {
chunk.reason.push(rejectListeners[i]);
}
}
} else {
chunk.reason = rejectListeners;
}
break;
case ERRORED:
if (rejectListeners) {
Expand Down

0 comments on commit c7c7ef2

Please sign in to comment.