@samitouri / QOS-React-1 / commits / 811e203ed4

[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.

Sebastian Markbåge committed Jun 27, 2025 at 16:27 UTC 811e203ed42c1a496790426a687d5045c473653d
1 file changed +36 -30
packages/react-client/src/ReactFlightClient.js
+36 -30
@@ -702,14 +702,16 @@ export function reportGlobalError(response: Response, error: Error): void {
702 }
703 }
704 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 + }
715 }
716 }
717
@@ -1838,7 +1840,9 @@ function ResponseInstance(
1840 if (enableProfilerTimer && enableComponentPerformanceTrack) {
1841 // Since we don't know when recording of profiles will start and stop, we have to
1842 // mark the order over and over again.
1841 - markAllTracksInOrder();
1843 + if (replayConsole) {
1844 + markAllTracksInOrder();
1845 + }
1846 }
1847
1848 // 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 {
2967 // $FlowFixMe[cannot-write]
2968 ioInfo.end += response._timeOrigin;
2969
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);
2993 }
2986 - } else {
2987 - logIOInfo(ioInfo, env, undefined);
2994 }
2995 }
2996