Skip to content

Commit 811e203

Browse files
authored
[Flight] Don't replay performance logs when replayConsoleLogs is false (#33656)
This is the same principle. They're both side-effects and go to the `console.*` namespace.
1 parent d92056e commit 811e203

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -702,14 +702,16 @@ export function reportGlobalError(response: Response, error: Error): void {
702702
}
703703
}
704704
if (enableProfilerTimer && enableComponentPerformanceTrack) {
705-
markAllTracksInOrder();
706-
flushComponentPerformance(
707-
response,
708-
getChunk(response, 0),
709-
0,
710-
-Infinity,
711-
-Infinity,
712-
);
705+
if (response._replayConsole) {
706+
markAllTracksInOrder();
707+
flushComponentPerformance(
708+
response,
709+
getChunk(response, 0),
710+
0,
711+
-Infinity,
712+
-Infinity,
713+
);
714+
}
713715
}
714716
}
715717

@@ -1838,7 +1840,9 @@ function ResponseInstance(
18381840
if (enableProfilerTimer && enableComponentPerformanceTrack) {
18391841
// Since we don't know when recording of profiles will start and stop, we have to
18401842
// mark the order over and over again.
1841-
markAllTracksInOrder();
1843+
if (replayConsole) {
1844+
markAllTracksInOrder();
1845+
}
18421846
}
18431847

18441848
// Don't inline this call because it causes closure to outline the call above.
@@ -2963,28 +2967,30 @@ function initializeIOInfo(response: Response, ioInfo: ReactIOInfo): void {
29632967
// $FlowFixMe[cannot-write]
29642968
ioInfo.end += response._timeOrigin;
29652969

2966-
const env = response._rootEnvironmentName;
2967-
const promise = ioInfo.value;
2968-
if (promise) {
2969-
const thenable: Thenable<mixed> = (promise: any);
2970-
switch (thenable.status) {
2971-
case INITIALIZED:
2972-
logIOInfo(ioInfo, env, thenable.value);
2973-
break;
2974-
case ERRORED:
2975-
logIOInfoErrored(ioInfo, env, thenable.reason);
2976-
break;
2977-
default:
2978-
// If we haven't resolved the Promise yet, wait to log until have so we can include
2979-
// its data in the log.
2980-
promise.then(
2981-
logIOInfo.bind(null, ioInfo, env),
2982-
logIOInfoErrored.bind(null, ioInfo, env),
2983-
);
2984-
break;
2970+
if (response._replayConsole) {
2971+
const env = response._rootEnvironmentName;
2972+
const promise = ioInfo.value;
2973+
if (promise) {
2974+
const thenable: Thenable<mixed> = (promise: any);
2975+
switch (thenable.status) {
2976+
case INITIALIZED:
2977+
logIOInfo(ioInfo, env, thenable.value);
2978+
break;
2979+
case ERRORED:
2980+
logIOInfoErrored(ioInfo, env, thenable.reason);
2981+
break;
2982+
default:
2983+
// If we haven't resolved the Promise yet, wait to log until have so we can include
2984+
// its data in the log.
2985+
promise.then(
2986+
logIOInfo.bind(null, ioInfo, env),
2987+
logIOInfoErrored.bind(null, ioInfo, env),
2988+
);
2989+
break;
2990+
}
2991+
} else {
2992+
logIOInfo(ioInfo, env, undefined);
29852993
}
2986-
} else {
2987-
logIOInfo(ioInfo, env, undefined);
29882994
}
29892995
}
29902996

0 commit comments

Comments
 (0)