Skip to content

Commit b1baf10

Browse files
committed
We need to read _debugInfo after a promise resolves since it's not guaranteed to be set yet
1 parent ce94aca commit b1baf10

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -687,22 +687,29 @@ function serializeThenable(
687687
__DEV__ ? task.debugStack : null,
688688
__DEV__ ? task.debugTask : null,
689689
);
690-
if (__DEV__) {
691-
// If this came from Flight, forward any debug info into this new row.
692-
const debugInfo: ?ReactDebugInfo = (thenable: any)._debugInfo;
693-
if (debugInfo) {
694-
forwardDebugInfo(request, newTask, debugInfo);
695-
}
696-
}
697690

698691
switch (thenable.status) {
699692
case 'fulfilled': {
693+
if (__DEV__) {
694+
// If this came from Flight, forward any debug info into this new row.
695+
const debugInfo: ?ReactDebugInfo = (thenable: any)._debugInfo;
696+
if (debugInfo) {
697+
forwardDebugInfo(request, newTask, debugInfo);
698+
}
699+
}
700700
// We have the resolved value, we can go ahead and schedule it for serialization.
701701
newTask.model = thenable.value;
702702
pingTask(request, newTask);
703703
return newTask.id;
704704
}
705705
case 'rejected': {
706+
if (__DEV__) {
707+
// If this came from Flight, forward any debug info into this new row.
708+
const debugInfo: ?ReactDebugInfo = (thenable: any)._debugInfo;
709+
if (debugInfo) {
710+
forwardDebugInfo(request, newTask, debugInfo);
711+
}
712+
}
706713
const x = thenable.reason;
707714
erroredTask(request, newTask, x);
708715
return newTask.id;
@@ -751,10 +758,24 @@ function serializeThenable(
751758

752759
thenable.then(
753760
value => {
761+
if (__DEV__) {
762+
// If this came from Flight, forward any debug info into this new row.
763+
const debugInfo: ?ReactDebugInfo = (thenable: any)._debugInfo;
764+
if (debugInfo) {
765+
forwardDebugInfo(request, newTask, debugInfo);
766+
}
767+
}
754768
newTask.model = value;
755769
pingTask(request, newTask);
756770
},
757771
reason => {
772+
if (__DEV__) {
773+
// If this came from Flight, forward any debug info into this new row.
774+
const debugInfo: ?ReactDebugInfo = (thenable: any)._debugInfo;
775+
if (debugInfo) {
776+
forwardDebugInfo(request, newTask, debugInfo);
777+
}
778+
}
758779
if (newTask.status === PENDING) {
759780
// We expect that the only status it might be otherwise is ABORTED.
760781
// When we abort we emit chunks in each pending task slot and don't need

0 commit comments

Comments
 (0)