[flags] Remove enableServerComponentLogs (#31772)
This has landed everywhere.
Ricky committed
Jan 3, 2025 at 12:53 UTC
f42f8c0635775c3cb8beb5252aa777ff7d468ae5
10 files changed
+37
-91
packages/react-client/src/ReactFlightClient.js
+13
-31
@@ -45,7 +45,6 @@ import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';
45
import {
46
enablePostpone,
47
enableOwnerStacks,
48
- enableServerComponentLogs,
48
enableProfilerTimer,
49
enableComponentPerformanceTrack,
50
} from 'shared/ReactFeatureFlags';
@@ -2139,34 +2138,22 @@ function resolveErrorDev(
2138
}
2139
2140
let error;
2142
- if (!enableOwnerStacks && !enableServerComponentLogs) {
2143
- // Executing Error within a native stack isn't really limited to owner stacks
2144
- // but we gate it behind the same flag for now while iterating.
2145
- // eslint-disable-next-line react-internal/prod-error-codes
2146
- error = Error(
2141
+ const callStack = buildFakeCallStack(
2142
+ response,
2143
+ stack,
2144
+ env,
2145
+ // $FlowFixMe[incompatible-use]
2146
+ Error.bind(
2147
+ null,
2148
message ||
2149
'An error occurred in the Server Components render but no message was provided',
2149
- );
2150
- // For backwards compat we use the V8 formatting when the flag is off.
2151
- error.stack = formatV8Stack(error.name, error.message, stack);
2150
+ ),
2151
+ );
2152
+ const rootTask = getRootTask(response, env);
2153
+ if (rootTask != null) {
2154
+ error = rootTask.run(callStack);
2155
} else {
2153
- const callStack = buildFakeCallStack(
2154
- response,
2155
- stack,
2156
- env,
2157
- // $FlowFixMe[incompatible-use]
2158
- Error.bind(
2159
- null,
2160
- message ||
2161
- 'An error occurred in the Server Components render but no message was provided',
2162
- ),
2163
- );
2164
- const rootTask = getRootTask(response, env);
2165
- if (rootTask != null) {
2166
- error = rootTask.run(callStack);
2167
- } else {
2168
- error = callStack();
2169
- }
2156
+ error = callStack();
2157
}
2158
2159
(error: any).environmentName = env;
@@ -2699,11 +2686,6 @@ function resolveConsoleEntry(
2686
const env = payload[3];
2687
const args = payload.slice(4);
2688
2702
- if (!enableOwnerStacks && !enableServerComponentLogs) {
2703
- bindToConsole(methodName, args, env)();
2704
- return;
2705
- }
2706
-
2689
replayConsoleWithCallStackInDEV(
2690
response,
2691
methodName,
packages/react-client/src/__tests__/ReactFlight-test.js
+23
-44
@@ -1377,26 +1377,14 @@ describe('ReactFlight', () => {
1377
errors: [
1378
{
1379
message: 'This is an error',
1380
- stack: gate(
1381
- flags =>
1382
- flags.enableOwnerStacks || flags.enableServerComponentLogs,
1383
- )
1384
- ? expect.stringContaining(
1385
- 'Error: This is an error\n' +
1386
- ' at eval (eval at testFunction (inspected-page.html:29:11),%20%3Canonymous%3E:1:35)\n' +
1387
- ' at ServerComponentError (file://~/(some)(really)(exotic-directory)/ReactFlight-test.js:1166:19)\n' +
1388
- ' at <anonymous> (file:///testing.js:42:3)\n' +
1389
- ' at <anonymous> (file:///testing.js:42:3)\n' +
1390
- ' at div (<anonymous>',
1391
- )
1392
- : expect.stringContaining(
1393
- 'Error: This is an error\n' +
1394
- ' at eval (eval at testFunction (inspected-page.html:29:11),%20%3Canonymous%3E:1:10)\n' +
1395
- ' at ServerComponentError (file://~/(some)(really)(exotic-directory)/ReactFlight-test.js:1166:19)\n' +
1396
- ' at file:///testing.js:42:3\n' +
1397
- ' at file:///testing.js:42:3\n' +
1398
- ' at div (<anonymous>',
1399
- ),
1380
+ stack: expect.stringContaining(
1381
+ 'Error: This is an error\n' +
1382
+ ' at eval (eval at testFunction (inspected-page.html:29:11),%20%3Canonymous%3E:1:35)\n' +
1383
+ ' at ServerComponentError (file://~/(some)(really)(exotic-directory)/ReactFlight-test.js:1166:19)\n' +
1384
+ ' at <anonymous> (file:///testing.js:42:3)\n' +
1385
+ ' at <anonymous> (file:///testing.js:42:3)\n' +
1386
+ ' at div (<anonymous>',
1387
+ ),
1388
digest: 'a dev digest',
1389
environmentName: 'Server',
1390
},
@@ -1415,18 +1403,16 @@ describe('ReactFlight', () => {
1403
['', 'Server'],
1404
[__filename, 'Server'],
1405
]
1418
- : gate(flags => flags.enableServerComponentLogs)
1419
- ? [
1420
- // TODO: What should we request here? The outer (<anonymous>) or the inner (inspected-page.html)?
1421
- ['inspected-page.html:29:11), <anonymous>', 'Server'],
1422
- [
1423
- 'file://~/(some)(really)(exotic-directory)/ReactFlight-test.js',
1424
- 'Server',
1425
- ],
1426
- ['file:///testing.js', 'Server'],
1427
- ['', 'Server'],
1428
- ]
1429
- : [],
1406
+ : [
1407
+ // TODO: What should we request here? The outer (<anonymous>) or the inner (inspected-page.html)?
1408
+ ['inspected-page.html:29:11), <anonymous>', 'Server'],
1409
+ [
1410
+ 'file://~/(some)(really)(exotic-directory)/ReactFlight-test.js',
1411
+ 'Server',
1412
+ ],
1413
+ ['file:///testing.js', 'Server'],
1414
+ ['', 'Server'],
1415
+ ],
1416
});
1417
} else {
1418
expect(errors.map(getErrorForJestMatcher)).toEqual([
@@ -3312,14 +3298,7 @@ describe('ReactFlight', () => {
3298
.split('\n')
3299
.slice(0, 4)
3300
.join('\n')
3315
- .replaceAll(
3316
- ' (/',
3317
- gate(
3318
- flags => flags.enableOwnerStacks || flags.enableServerComponentLogs,
3319
- )
3320
- ? ' (file:///'
3321
- : ' (/',
3322
- ); // The eval will end up normalizing these
3301
+ .replaceAll(' (/', ' (file:///'); // The eval will end up normalizing these
3302
3303
let sawReactPrefix = false;
3304
const environments = [];
@@ -3352,7 +3331,7 @@ describe('ReactFlight', () => {
3331
'third-party',
3332
'third-party',
3333
]);
3355
- } else if (__DEV__ && gate(flags => flags.enableServerComponentLogs)) {
3334
+ } else if (__DEV__) {
3335
expect(environments.slice(0, 3)).toEqual([
3336
'third-party',
3337
'third-party',
@@ -3412,7 +3391,7 @@ describe('ReactFlight', () => {
3391
expect(ReactNoop).toMatchRenderedOutput(<div>hi</div>);
3392
});
3393
3415
- // @gate enableServerComponentLogs && __DEV__ && enableOwnerStacks
3394
+ // @gate __DEV__ && enableOwnerStacks
3395
it('replays logs, but not onError logs', async () => {
3396
function foo() {
3397
return 'hello';
@@ -3493,7 +3472,7 @@ describe('ReactFlight', () => {
3472
expect(ownerStacks).toEqual(['\n in App (at **)']);
3473
});
3474
3496
- // @gate enableServerComponentLogs && __DEV__
3475
+ // @gate __DEV__
3476
it('replays logs with cyclic objects', async () => {
3477
const cyclic = {cycle: null};
3478
cyclic.cycle = cyclic;
@@ -3764,7 +3743,7 @@ describe('ReactFlight', () => {
3743
);
3744
});
3745
3767
- // @gate (enableOwnerStacks && enableServerComponentLogs) || !__DEV__
3746
+ // @gate (enableOwnerStacks) || !__DEV__
3747
it('should include only one component stack in replayed logs (if DevTools or polyfill adds them)', () => {
3748
class MyError extends Error {
3749
toJSON() {
packages/react-server/src/ReactFlightServer.js
+1
-7
@@ -17,7 +17,6 @@ import {
17
enablePostpone,
18
enableHalt,
19
enableTaint,
20
- enableServerComponentLogs,
20
enableOwnerStacks,
21
enableProfilerTimer,
22
enableComponentPerformanceTrack,
@@ -234,12 +233,7 @@ function patchConsole(consoleInst: typeof console, methodName: string) {
233
}
234
}
235
237
-if (
238
- enableServerComponentLogs &&
239
- __DEV__ &&
240
- typeof console === 'object' &&
241
- console !== null
242
-) {
236
+if (__DEV__ && typeof console === 'object' && console !== null) {
237
// Instrument console to capture logs for replaying on the client.
238
patchConsole(console, 'assert');
239
patchConsole(console, 'debug');
packages/shared/ReactFeatureFlags.js
-2
@@ -128,8 +128,6 @@ export const alwaysThrottleRetries = true;
128
129
export const passChildrenWhenCloningPersistedNodes = false;
130
131
-export const enableServerComponentLogs = true;
132
-
131
/**
132
* Enables a new Fiber flag used in persisted mode to reduce the number
133
* of cloned host components.
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -66,7 +66,6 @@ export const enableRetryLaneExpiration = false;
66
export const enableSchedulingProfiler = __PROFILE__;
67
export const enableComponentPerformanceTrack = false;
68
export const enableScopeAPI = false;
69
-export const enableServerComponentLogs = true;
69
export const enableSuspenseAvoidThisFallback = false;
70
export const enableSuspenseCallback = true;
71
export const enableTaint = true;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -52,7 +52,6 @@ export const enableRetryLaneExpiration = false;
52
export const enableSchedulingProfiler = __PROFILE__;
53
export const enableComponentPerformanceTrack = false;
54
export const enableScopeAPI = false;
55
-export const enableServerComponentLogs = true;
55
export const enableShallowPropDiffing = false;
56
export const enableSuspenseAvoidThisFallback = false;
57
export const enableSuspenseCallback = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -61,7 +61,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
61
export const enablePersistedModeClonedFlag = false;
62
export const disableClientCache = true;
63
64
-export const enableServerComponentLogs = true;
64
export const enableInfiniteRenderLoopDetection = false;
65
66
export const renameElementSymbol = true;
packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
-1
@@ -49,7 +49,6 @@ export const enableRetryLaneExpiration = false;
49
export const enableSchedulingProfiler = __PROFILE__;
50
export const enableComponentPerformanceTrack = false;
51
export const enableScopeAPI = false;
52
-export const enableServerComponentLogs = true;
52
export const enableShallowPropDiffing = false;
53
export const enableSuspenseAvoidThisFallback = false;
54
export const enableSuspenseCallback = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -63,7 +63,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
63
export const enablePersistedModeClonedFlag = false;
64
export const disableClientCache = true;
65
66
-export const enableServerComponentLogs = true;
66
export const enableInfiniteRenderLoopDetection = false;
67
68
export const enableReactTestRendererWarning = false;
packages/shared/forks/ReactFeatureFlags.www.js
-2
@@ -104,8 +104,6 @@ export const enablePersistedModeClonedFlag = false;
104
export const enableAsyncDebugInfo = false;
105
export const disableClientCache = true;
106
107
-export const enableServerComponentLogs = true;
108
-
107
export const enableReactTestRendererWarning = false;
108
109
export const disableLegacyMode = true;