Skip to content
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

Update ReactDebugInfo types to declare timing info separately #31714

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Refine type of debug chunk
  • Loading branch information
sebmarkbage committed Dec 10, 2024
commit 97c0a4495ce79c6ffbffd04bcdf1b9b57534874c
38 changes: 30 additions & 8 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import type {
Thenable,
ReactDebugInfo,
ReactComponentInfo,
ReactEnvironmentInfo,
ReactAsyncInfo,
ReactTimeInfo,
ReactStackTrace,
ReactCallSite,
} from 'shared/ReactTypes';
Expand Down Expand Up @@ -2471,7 +2473,11 @@ function initializeFakeStack(
function resolveDebugInfo(
response: Response,
id: number,
debugInfo: ReactComponentInfo | ReactAsyncInfo,
debugInfo:
| ReactComponentInfo
| ReactEnvironmentInfo
| ReactAsyncInfo
| ReactTimeInfo,
): void {
if (!__DEV__) {
// These errors should never make it into a build so we don't need to encode them in codes.json
Expand All @@ -2485,7 +2491,12 @@ function resolveDebugInfo(
// to initialize it when we need it, we might be inside user code.
const env =
debugInfo.env === undefined ? response._rootEnvironmentName : debugInfo.env;
initializeFakeTask(response, debugInfo, env);
if (debugInfo.stack !== undefined) {
const componentInfoOrAsyncInfo: ReactComponentInfo | ReactAsyncInfo =
// $FlowFixMe[incompatible-type]
debugInfo;
initializeFakeTask(response, componentInfoOrAsyncInfo, env);
}
if (debugInfo.owner === null && response._debugRootOwner != null) {
// $FlowFixMe[prop-missing] By narrowing `owner` to `null`, we narrowed `debugInfo` to `ReactComponentInfo`
const componentInfo: ReactComponentInfo = debugInfo;
Expand All @@ -2495,8 +2506,11 @@ function resolveDebugInfo(
// was created on the server isn't very useful but where the request was made is.
// $FlowFixMe[cannot-write]
componentInfo.debugStack = response._debugRootStack;
} else {
initializeFakeStack(response, debugInfo);
} else if (debugInfo.stack !== undefined) {
const componentInfoOrAsyncInfo: ReactComponentInfo | ReactAsyncInfo =
// $FlowFixMe[incompatible-type]
debugInfo;
initializeFakeStack(response, componentInfoOrAsyncInfo);
}

const chunk = getChunk(response, id);
Expand Down Expand Up @@ -2780,11 +2794,19 @@ function processFullStringRow(
}
case 68 /* "D" */: {
if (__DEV__) {
const chunk: ResolvedModelChunk<ReactComponentInfo | ReactAsyncInfo> =
createResolvedModelChunk(response, row);
const chunk: ResolvedModelChunk<
| ReactComponentInfo
| ReactEnvironmentInfo
| ReactAsyncInfo
| ReactTimeInfo,
> = createResolvedModelChunk(response, row);
initializeModelChunk(chunk);
const initializedChunk: SomeChunk<ReactComponentInfo | ReactAsyncInfo> =
chunk;
const initializedChunk: SomeChunk<
| ReactComponentInfo
| ReactEnvironmentInfo
| ReactAsyncInfo
| ReactTimeInfo,
> = chunk;
if (initializedChunk.status === INITIALIZED) {
resolveDebugInfo(response, id, initializedChunk.value);
} else {
Expand Down
Loading