Skip to content

[pull] main from facebook:main #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/react-client/src/ReactFlightPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,13 @@ function getIOShortName(
const slashIdx = description.lastIndexOf('/', queryIdx - 1);
if (queryIdx - slashIdx < descMaxLength) {
// This may now be either the file name or the host.
desc = ' (' + description.slice(slashIdx + 1, queryIdx) + ')';
// Include the slash to make it more obvious what we trimmed.
desc = ' (…' + description.slice(slashIdx, queryIdx) + ')';
} else {
// cut out the middle to not exceed the max length
const start = description.slice(slashIdx, slashIdx + descMaxLength / 2);
const end = description.slice(queryIdx - descMaxLength / 2, queryIdx);
desc = ' (' + (slashIdx > 0 ? '…' : '') + start + '…' + end + ')';
}
}
}
Expand Down
58 changes: 51 additions & 7 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,16 @@ function renderFunctionComponent<Props>(
// Apply special cases.
result = processServerComponentReturnValue(request, task, Component, result);

if (__DEV__) {
// From this point on, the parent is the component we just rendered until we
// hit another JSX element.
task.debugOwner = componentDebugInfo;
// Unfortunately, we don't have a stack frame for this position. Conceptually
// it would be the ___location of the `return` inside component that just rendered.
task.debugStack = null;
task.debugTask = null;
}

// Track this element's key on the Server Component on the keyPath context..
const prevKeyPath = task.keyPath;
const prevImplicitSlot = task.implicitSlot;
Expand Down Expand Up @@ -2317,6 +2327,21 @@ function visitAsyncNode(
// then this gets I/O ignored, which is what we want because it means it was likely
// just part of a previous component's rendering.
match = ioNode;
if (
node.stack !== null &&
isAwaitInUserspace(request, node.stack)
) {
// This await happened earlier but it was done in user space. This is the first time
// that user space saw the value of the I/O. We know we'll emit the I/O eventually
// but if we do it now we can override the promise value of the I/O entry to the
// one observed by this await which will be a better value than the internals of
// the I/O entry. If it's still alive that is.
const promise =
awaited.promise === null ? undefined : awaited.promise.deref();
if (promise !== undefined) {
serializeIONode(request, ioNode, awaited.promise);
}
}
} else {
if (
node.stack === null ||
Expand Down Expand Up @@ -2416,13 +2441,32 @@ function emitAsyncSequence(
env: env,
};
if (__DEV__) {
if (owner != null) {
// $FlowFixMe[cannot-write]
debugInfo.owner = owner;
}
if (stack != null) {
// $FlowFixMe[cannot-write]
debugInfo.stack = filterStackTrace(request, parseStackTrace(stack, 1));
if (owner === null && stack === null) {
// We have no ___location for the await. We can use the JSX callsite of the parent
// as the await if this was just passed as a prop.
if (task.debugOwner !== null) {
// $FlowFixMe[cannot-write]
debugInfo.owner = task.debugOwner;
}
if (task.debugStack !== null) {
// $FlowFixMe[cannot-write]
debugInfo.stack = filterStackTrace(
request,
parseStackTrace(task.debugStack, 1),
);
}
} else {
if (owner != null) {
// $FlowFixMe[cannot-write]
debugInfo.owner = owner;
}
if (stack != null) {
// $FlowFixMe[cannot-write]
debugInfo.stack = filterStackTrace(
request,
parseStackTrace(stack, 1),
);
}
}
}
// We don't have a start time for this await but in case there was no start time emitted
Expand Down
Loading
Loading