Skip to content

Commit f3a8036

Browse files
authored
[Flight] Ensure async info owners are outlined properly (#34465)
When we emit objects of type `ReactAsyncInfo`, we need to make sure that their owners are outlined, using `outlineComponentInfo`. Otherwise we would end up accidentally emitting stashed fields that are not part of the transport protocol, specifically `debugStack`, `debugTask`, and `debugLocation`. This would lead to runtime errors in the client, when for example, the stack for a `debugLocation` is processed in `buildFakeCallStack`, but the stack was actually omitted from the RSC payload, because for those fields we don't ensure that the object limit is increased by the length of the stack, as we do when we're emitting the `stack` of a `ReactComponentInfo` object in `outlineComponentInfo`.
1 parent fe84397 commit f3a8036

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,6 +2384,11 @@ function visitAsyncNode(
23842384
// Promise that was ultimately awaited by the user space await.
23852385
serializeIONode(request, ioNode, awaited.promise);
23862386

2387+
// Ensure the owner is already outlined.
2388+
if (node.owner != null) {
2389+
outlineComponentInfo(request, node.owner);
2390+
}
2391+
23872392
// We log the environment at the time when the last promise pigned ping which may
23882393
// be later than what the environment was when we actually started awaiting.
23892394
const env = (0, request.environmentName)();
@@ -5133,6 +5138,10 @@ function forwardDebugInfo(
51335138
} else {
51345139
// Outline the IO info in case the same I/O is awaited in more than one place.
51355140
outlineIOInfo(request, ioInfo);
5141+
// Ensure the owner is already outlined.
5142+
if (info.owner != null) {
5143+
outlineComponentInfo(request, info.owner);
5144+
}
51365145
// We can't serialize the ConsoleTask/Error objects so we need to omit them before serializing.
51375146
let debugStack;
51385147
if (info.stack == null && info.debugStack != null) {

0 commit comments

Comments
 (0)