Skip to content

Commit

Permalink
Sort Server Components Track Group ahead of Client Scheduler/Componen…
Browse files Browse the repository at this point in the history
…ts Tracks
  • Loading branch information
sebmarkbage committed Dec 12, 2024
1 parent 3c83561 commit 99299ec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
6 changes: 5 additions & 1 deletion packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ import {createBoundServerReference} from './ReactFlightReplyClient';

import {readTemporaryReference} from './ReactFlightTemporaryReferences';

import {logComponentRender} from './ReactFlightPerformanceTrack';
import {
markAllTracksInOrder,
logComponentRender,
} from './ReactFlightPerformanceTrack';

import {
REACT_LAZY_TYPE,
Expand Down Expand Up @@ -649,6 +652,7 @@ export function reportGlobalError(response: Response, error: Error): void {
}
});
if (enableProfilerTimer && enableComponentPerformanceTrack) {
markAllTracksInOrder();
flushComponentPerformance(getChunk(response, 0), 0, -Infinity);
}
}
Expand Down
20 changes: 20 additions & 0 deletions packages/react-client/src/ReactFlightPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ const supportsUserTiming =

const COMPONENTS_TRACK = 'Server Components ⚛';

const componentsTrackMarker = {
startTime: 0.001,
detail: {
devtools: {
color: 'primary-light',
track: 'Primary',
trackGroup: COMPONENTS_TRACK,
},
},
};

export function markAllTracksInOrder() {
if (supportsUserTiming) {
// Ensure we create the Server Component track groups earlier than the Client Scheduler
// and Client Components. We can always add the 0 time slot even if it's in the past.
// That's still considered for ordering.
performance.mark('Server Components Track', componentsTrackMarker);
}
}

// Reused to avoid thrashing the GC.
const reusableComponentDevToolDetails = {
color: 'primary',
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function setCurrentTrackFromLanes(lanes: number): void {
}

const blockingLaneMarker = {
startTime: 0,
startTime: 0.003,
detail: {
devtools: {
color: 'primary-light',
Expand All @@ -67,7 +67,7 @@ const blockingLaneMarker = {
};

const transitionLaneMarker = {
startTime: 0,
startTime: 0.003,
detail: {
devtools: {
color: 'primary-light',
Expand All @@ -78,7 +78,7 @@ const transitionLaneMarker = {
};

const suspenseLaneMarker = {
startTime: 0,
startTime: 0.003,
detail: {
devtools: {
color: 'primary-light',
Expand All @@ -89,7 +89,7 @@ const suspenseLaneMarker = {
};

const idleLaneMarker = {
startTime: 0,
startTime: 0.003,
detail: {
devtools: {
color: 'primary-light',
Expand Down

0 comments on commit 99299ec

Please sign in to comment.