Skip to content

Commit 4af2c23

Browse files
committed
Move counter to isomorphic, dev React
1 parent 2f98cb4 commit 4af2c23

12 files changed

+31
-41
lines changed

Diff for: packages/react/src/ReactSharedInternalsClient.js

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export type SharedStateClient = {
3838

3939
// ReactDebugCurrentFrame
4040
getCurrentStack: null | (() => string),
41+
42+
recentlyCreatedOwnerStacks: 0,
4143
};
4244

4345
export type RendererTask = boolean => RendererTask | null;
@@ -58,6 +60,14 @@ if (__DEV__) {
5860
ReactSharedInternals.thrownErrors = [];
5961
// Stack implementation injected by the current renderer.
6062
ReactSharedInternals.getCurrentStack = (null: null | (() => string));
63+
ReactSharedInternals.recentlyCreatedOwnerStacks = 0;
64+
65+
if (typeof setInterval === 'function') {
66+
// TODO: Stop outside of rendering.
67+
setInterval(() => {
68+
ReactSharedInternals.recentlyCreatedOwnerStacks = 0;
69+
}, 1000);
70+
}
6171
}
6272

6373
export default ReactSharedInternals;

Diff for: packages/react/src/ReactSharedInternalsServer.js

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export type SharedStateServer = {
3939

4040
// ReactDebugCurrentFrame
4141
getCurrentStack: null | (() => string),
42+
43+
//
44+
recentlyCreatedOwnerStacks: 0,
4245
};
4346

4447
export type RendererTask = boolean => RendererTask | null;
@@ -59,6 +62,8 @@ if (enableTaint) {
5962
if (__DEV__) {
6063
// Stack implementation injected by the current renderer.
6164
ReactSharedInternals.getCurrentStack = (null: null | (() => string));
65+
66+
ReactSharedInternals.recentlyCreatedOwnerStacks = 0;
6267
}
6368

6469
export default ReactSharedInternals;

Diff for: packages/react/src/jsx/ReactJSXElement.js

+16-18
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,9 @@ import {checkKeyStringCoercion} from 'shared/CheckStringCoercion';
1818
import isArray from 'shared/isArray';
1919
import {
2020
disableDefaultPropsExceptForClasses,
21-
debugInfoLimitsResetIntervalMs,
22-
debugTaskLimit,
2321
ownerStackLimit,
2422
} from 'shared/ReactFeatureFlags';
2523

26-
let recentlyCreatedOwnerStacks = 0;
27-
let recentlyCreatedDebugTasks = 0;
28-
setInterval(() => {
29-
recentlyCreatedOwnerStacks = 0;
30-
recentlyCreatedDebugTasks = 0;
31-
}, debugInfoLimitsResetIntervalMs);
32-
3324
const createTask =
3425
// eslint-disable-next-line react-internal/no-production-logging
3526
__DEV__ && console.createTask
@@ -396,6 +387,8 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren(
396387
) {
397388
if (__DEV__) {
398389
const isStaticChildren = false;
390+
const trackActualOwner =
391+
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
399392
return jsxDEVImpl(
400393
type,
401394
config,
@@ -404,11 +397,11 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren(
404397
source,
405398
self,
406399
__DEV__ &&
407-
(recentlyCreatedOwnerStacks++ < ownerStackLimit
400+
(trackActualOwner
408401
? Error('react-stack-top-frame')
409402
: unknownOwnerDebugStack),
410403
__DEV__ &&
411-
(recentlyCreatedDebugTasks++ < debugTaskLimit
404+
(trackActualOwner
412405
? createTask(getTaskName(type))
413406
: unknownOwnerDebugTask),
414407
);
@@ -424,6 +417,8 @@ export function jsxProdSignatureRunningInDevWithStaticChildren(
424417
) {
425418
if (__DEV__) {
426419
const isStaticChildren = true;
420+
const trackActualOwner =
421+
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
427422
return jsxDEVImpl(
428423
type,
429424
config,
@@ -432,11 +427,11 @@ export function jsxProdSignatureRunningInDevWithStaticChildren(
432427
source,
433428
self,
434429
__DEV__ &&
435-
(recentlyCreatedOwnerStacks++ < ownerStackLimit
430+
(trackActualOwner
436431
? Error('react-stack-top-frame')
437432
: unknownOwnerDebugStack),
438433
__DEV__ &&
439-
(recentlyCreatedDebugTasks++ < debugTaskLimit
434+
(trackActualOwner
440435
? createTask(getTaskName(type))
441436
: unknownOwnerDebugTask),
442437
);
@@ -452,6 +447,8 @@ const didWarnAboutKeySpread = {};
452447
* @param {string} key
453448
*/
454449
export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
450+
const trackActualOwner =
451+
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
455452
return jsxDEVImpl(
456453
type,
457454
config,
@@ -460,11 +457,11 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
460457
source,
461458
self,
462459
__DEV__ &&
463-
(recentlyCreatedOwnerStacks++ < ownerStackLimit
460+
(trackActualOwner
464461
? Error('react-stack-top-frame')
465462
: unknownOwnerDebugStack),
466463
__DEV__ &&
467-
(recentlyCreatedDebugTasks++ < debugTaskLimit
464+
(trackActualOwner
468465
? createTask(getTaskName(type))
469466
: unknownOwnerDebugTask),
470467
);
@@ -733,7 +730,8 @@ export function createElement(type, config, children) {
733730
defineKeyPropWarningGetter(props, displayName);
734731
}
735732
}
736-
733+
const trackActualOwner =
734+
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
737735
return ReactElement(
738736
type,
739737
key,
@@ -742,11 +740,11 @@ export function createElement(type, config, children) {
742740
getOwner(),
743741
props,
744742
__DEV__ &&
745-
(recentlyCreatedOwnerStacks++ < ownerStackLimit
743+
(trackActualOwner
746744
? Error('react-stack-top-frame')
747745
: unknownOwnerDebugStack),
748746
__DEV__ &&
749-
(recentlyCreatedDebugTasks++ < debugTaskLimit
747+
(trackActualOwner
750748
? createTask(getTaskName(type))
751749
: unknownOwnerDebugTask),
752750
);

Diff for: packages/shared/ReactFeatureFlags.js

-2
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,3 @@ export const enableUpdaterTracking = __PROFILE__;
269269
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
270270

271271
export const ownerStackLimit = 1e4;
272-
export const debugTaskLimit = 1e4;
273-
export const debugInfoLimitsResetIntervalMs = 1000;

Diff for: packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js

-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,3 @@ export const ownerStackLimit: number = __VARIANT__
3232
? // Some value that doesn't impact existing tests
3333
500
3434
: 1e4;
35-
export const debugTaskLimit: number = __VARIANT__
36-
? // Some value that doesn't impact existing tests
37-
500
38-
: 1e4;
39-
export const debugInfoLimitsResetIntervalMs: number = __VARIANT__ ? 1000 : 2000;

Diff for: packages/shared/forks/ReactFeatureFlags.native-fb.js

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export const {
3131
enableFastAddPropertiesInDiffing,
3232
enableLazyPublicInstanceInFabric,
3333
ownerStackLimit,
34-
debugTaskLimit,
35-
debugInfoLimitsResetIntervalMs,
3634
} = dynamicFlags;
3735

3836
// The rest of the flags are static for better dead code elimination.

Diff for: packages/shared/forks/ReactFeatureFlags.native-oss.js

-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ export const enableFastAddPropertiesInDiffing = false;
7676
export const enableLazyPublicInstanceInFabric = false;
7777
export const enableScrollEndPolyfill = true;
7878
export const ownerStackLimit = 1e4;
79-
export const debugTaskLimit = 1e4;
80-
export const debugInfoLimitsResetIntervalMs = 1000;
8179

8280
// Profiling Only
8381
export const enableProfilerTimer = __PROFILE__;

Diff for: packages/shared/forks/ReactFeatureFlags.test-renderer.js

-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ export const enableFastAddPropertiesInDiffing = true;
7676
export const enableLazyPublicInstanceInFabric = false;
7777
export const enableScrollEndPolyfill = true;
7878
export const ownerStackLimit = 1e4;
79-
export const debugTaskLimit = 1e4;
80-
export const debugInfoLimitsResetIntervalMs = 1000;
8179

8280
// TODO: This must be in sync with the main ReactFeatureFlags file because
8381
// the Test Renderer's value must be the same as the one used by the

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

-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ export const enableFastAddPropertiesInDiffing = false;
7272
export const enableLazyPublicInstanceInFabric = false;
7373
export const enableScrollEndPolyfill = true;
7474
export const ownerStackLimit = 1e4;
75-
export const debugTaskLimit = 1e4;
76-
export const debugInfoLimitsResetIntervalMs = 1000;
7775

7876
// Flow magic to verify the exports of this file match the original version.
7977
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

Diff for: packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ export const enableLazyPublicInstanceInFabric = false;
8888
export const enableScrollEndPolyfill = true;
8989

9090
export const ownerStackLimit = 1e4;
91-
export const debugTaskLimit = 1e4;
92-
export const debugInfoLimitsResetIntervalMs = 1000;
9391

9492
// Flow magic to verify the exports of this file match the original version.
9593
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

Diff for: packages/shared/forks/ReactFeatureFlags.www-dynamic.js

-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ export const ownerStackLimit: number = __VARIANT__
4545
? // Some value that doesn't impact existing tests
4646
500
4747
: 1e4;
48-
export const debugTaskLimit: number = __VARIANT__
49-
? // Some value that doesn't impact existing tests
50-
500
51-
: 1e4;
52-
export const debugInfoLimitsResetIntervalMs: number = __VARIANT__ ? 1000 : 2000;
5348

5449
// TODO: These flags are hard-coded to the default values used in open source.
5550
// Update the tests so that they pass in either mode, then set these

Diff for: packages/shared/forks/ReactFeatureFlags.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const {
3939
enableViewTransition,
4040
enableScrollEndPolyfill,
4141
ownerStackLimit,
42-
debugTaskLimit,
4342
debugInfoLimitsResetIntervalMs,
4443
} = dynamicFeatureFlags;
4544

0 commit comments

Comments
 (0)