Skip to content

Commit f42f8c0

Browse files
authored
[flags] Remove enableServerComponentLogs (facebook#31772)
This has landed everywhere.
1 parent 3b009b4 commit f42f8c0

10 files changed

+37
-91
lines changed

packages/react-client/src/ReactFlightClient.js

+13-31
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';
4545
import {
4646
enablePostpone,
4747
enableOwnerStacks,
48-
enableServerComponentLogs,
4948
enableProfilerTimer,
5049
enableComponentPerformanceTrack,
5150
} from 'shared/ReactFeatureFlags';
@@ -2139,34 +2138,22 @@ function resolveErrorDev(
21392138
}
21402139

21412140
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,
21472148
message ||
21482149
'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);
21522155
} 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();
21702157
}
21712158

21722159
(error: any).environmentName = env;
@@ -2699,11 +2686,6 @@ function resolveConsoleEntry(
26992686
const env = payload[3];
27002687
const args = payload.slice(4);
27012688

2702-
if (!enableOwnerStacks && !enableServerComponentLogs) {
2703-
bindToConsole(methodName, args, env)();
2704-
return;
2705-
}
2706-
27072689
replayConsoleWithCallStackInDEV(
27082690
response,
27092691
methodName,

packages/react-client/src/__tests__/ReactFlight-test.js

+23-44
Original file line numberDiff line numberDiff line change
@@ -1377,26 +1377,14 @@ describe('ReactFlight', () => {
13771377
errors: [
13781378
{
13791379
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+
),
14001388
digest: 'a dev digest',
14011389
environmentName: 'Server',
14021390
},
@@ -1415,18 +1403,16 @@ describe('ReactFlight', () => {
14151403
['', 'Server'],
14161404
[__filename, 'Server'],
14171405
]
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+
],
14301416
});
14311417
} else {
14321418
expect(errors.map(getErrorForJestMatcher)).toEqual([
@@ -3312,14 +3298,7 @@ describe('ReactFlight', () => {
33123298
.split('\n')
33133299
.slice(0, 4)
33143300
.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
33233302

33243303
let sawReactPrefix = false;
33253304
const environments = [];
@@ -3352,7 +3331,7 @@ describe('ReactFlight', () => {
33523331
'third-party',
33533332
'third-party',
33543333
]);
3355-
} else if (__DEV__ && gate(flags => flags.enableServerComponentLogs)) {
3334+
} else if (__DEV__) {
33563335
expect(environments.slice(0, 3)).toEqual([
33573336
'third-party',
33583337
'third-party',
@@ -3412,7 +3391,7 @@ describe('ReactFlight', () => {
34123391
expect(ReactNoop).toMatchRenderedOutput(<div>hi</div>);
34133392
});
34143393

3415-
// @gate enableServerComponentLogs && __DEV__ && enableOwnerStacks
3394+
// @gate __DEV__ && enableOwnerStacks
34163395
it('replays logs, but not onError logs', async () => {
34173396
function foo() {
34183397
return 'hello';
@@ -3493,7 +3472,7 @@ describe('ReactFlight', () => {
34933472
expect(ownerStacks).toEqual(['\n in App (at **)']);
34943473
});
34953474

3496-
// @gate enableServerComponentLogs && __DEV__
3475+
// @gate __DEV__
34973476
it('replays logs with cyclic objects', async () => {
34983477
const cyclic = {cycle: null};
34993478
cyclic.cycle = cyclic;
@@ -3764,7 +3743,7 @@ describe('ReactFlight', () => {
37643743
);
37653744
});
37663745

3767-
// @gate (enableOwnerStacks && enableServerComponentLogs) || !__DEV__
3746+
// @gate (enableOwnerStacks) || !__DEV__
37683747
it('should include only one component stack in replayed logs (if DevTools or polyfill adds them)', () => {
37693748
class MyError extends Error {
37703749
toJSON() {

packages/react-server/src/ReactFlightServer.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
enablePostpone,
1818
enableHalt,
1919
enableTaint,
20-
enableServerComponentLogs,
2120
enableOwnerStacks,
2221
enableProfilerTimer,
2322
enableComponentPerformanceTrack,
@@ -234,12 +233,7 @@ function patchConsole(consoleInst: typeof console, methodName: string) {
234233
}
235234
}
236235

237-
if (
238-
enableServerComponentLogs &&
239-
__DEV__ &&
240-
typeof console === 'object' &&
241-
console !== null
242-
) {
236+
if (__DEV__ && typeof console === 'object' && console !== null) {
243237
// Instrument console to capture logs for replaying on the client.
244238
patchConsole(console, 'assert');
245239
patchConsole(console, 'debug');

packages/shared/ReactFeatureFlags.js

-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ export const alwaysThrottleRetries = true;
128128

129129
export const passChildrenWhenCloningPersistedNodes = false;
130130

131-
export const enableServerComponentLogs = true;
132-
133131
/**
134132
* Enables a new Fiber flag used in persisted mode to reduce the number
135133
* of cloned host components.

packages/shared/forks/ReactFeatureFlags.native-fb.js

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export const enableRetryLaneExpiration = false;
6666
export const enableSchedulingProfiler = __PROFILE__;
6767
export const enableComponentPerformanceTrack = false;
6868
export const enableScopeAPI = false;
69-
export const enableServerComponentLogs = true;
7069
export const enableSuspenseAvoidThisFallback = false;
7170
export const enableSuspenseCallback = true;
7271
export const enableTaint = true;

packages/shared/forks/ReactFeatureFlags.native-oss.js

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export const enableRetryLaneExpiration = false;
5252
export const enableSchedulingProfiler = __PROFILE__;
5353
export const enableComponentPerformanceTrack = false;
5454
export const enableScopeAPI = false;
55-
export const enableServerComponentLogs = true;
5655
export const enableShallowPropDiffing = false;
5756
export const enableSuspenseAvoidThisFallback = false;
5857
export const enableSuspenseCallback = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
6161
export const enablePersistedModeClonedFlag = false;
6262
export const disableClientCache = true;
6363

64-
export const enableServerComponentLogs = true;
6564
export const enableInfiniteRenderLoopDetection = false;
6665

6766
export const renameElementSymbol = true;

packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export const enableRetryLaneExpiration = false;
4949
export const enableSchedulingProfiler = __PROFILE__;
5050
export const enableComponentPerformanceTrack = false;
5151
export const enableScopeAPI = false;
52-
export const enableServerComponentLogs = true;
5352
export const enableShallowPropDiffing = false;
5453
export const enableSuspenseAvoidThisFallback = false;
5554
export const enableSuspenseCallback = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
6363
export const enablePersistedModeClonedFlag = false;
6464
export const disableClientCache = true;
6565

66-
export const enableServerComponentLogs = true;
6766
export const enableInfiniteRenderLoopDetection = false;
6867

6968
export const enableReactTestRendererWarning = false;

packages/shared/forks/ReactFeatureFlags.www.js

-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ export const enablePersistedModeClonedFlag = false;
104104
export const enableAsyncDebugInfo = false;
105105
export const disableClientCache = true;
106106

107-
export const enableServerComponentLogs = true;
108-
109107
export const enableReactTestRendererWarning = false;
110108

111109
export const disableLegacyMode = true;

0 commit comments

Comments
 (0)