Skip to content

Commit 54e6c53

Browse files
committed
Timerless based approach
Has the benefit of not suddenly resetting in the middle of render
1 parent 6c94991 commit 54e6c53

File tree

8 files changed

+176
-137
lines changed

8 files changed

+176
-137
lines changed

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

+24-24
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ describe('ReactFlight', () => {
315315
expect(getDebugInfo(greeting)).toEqual(
316316
__DEV__
317317
? [
318-
{time: 11},
318+
{time: 12},
319319
{
320320
name: 'Greeting',
321321
env: 'Server',
@@ -327,7 +327,7 @@ describe('ReactFlight', () => {
327327
lastName: 'Smith',
328328
},
329329
},
330-
{time: 12},
330+
{time: 13},
331331
]
332332
: undefined,
333333
);
@@ -359,7 +359,7 @@ describe('ReactFlight', () => {
359359
expect(getDebugInfo(promise)).toEqual(
360360
__DEV__
361361
? [
362-
{time: 11},
362+
{time: 12},
363363
{
364364
name: 'Greeting',
365365
env: 'Server',
@@ -371,7 +371,7 @@ describe('ReactFlight', () => {
371371
lastName: 'Smith',
372372
},
373373
},
374-
{time: 12},
374+
{time: 13},
375375
]
376376
: undefined,
377377
);
@@ -2807,7 +2807,7 @@ describe('ReactFlight', () => {
28072807
expect(getDebugInfo(promise)).toEqual(
28082808
__DEV__
28092809
? [
2810-
{time: 18},
2810+
{time: 20},
28112811
{
28122812
name: 'ServerComponent',
28132813
env: 'Server',
@@ -2818,7 +2818,7 @@ describe('ReactFlight', () => {
28182818
transport: expect.arrayContaining([]),
28192819
},
28202820
},
2821-
{time: 19},
2821+
{time: 21},
28222822
]
28232823
: undefined,
28242824
);
@@ -2829,7 +2829,7 @@ describe('ReactFlight', () => {
28292829
expect(getDebugInfo(thirdPartyChildren[0])).toEqual(
28302830
__DEV__
28312831
? [
2832-
{time: 13},
2832+
{time: 14},
28332833
{
28342834
name: 'ThirdPartyComponent',
28352835
env: 'third-party',
@@ -2838,15 +2838,15 @@ describe('ReactFlight', () => {
28382838
stack: ' in Object.<anonymous> (at **)',
28392839
props: {},
28402840
},
2841-
{time: 14},
2842-
{time: 21}, // This last one is when the promise resolved into the first party.
2841+
{time: 15},
2842+
{time: 23}, // This last one is when the promise resolved into the first party.
28432843
]
28442844
: undefined,
28452845
);
28462846
expect(getDebugInfo(thirdPartyChildren[1])).toEqual(
28472847
__DEV__
28482848
? [
2849-
{time: 15},
2849+
{time: 16},
28502850
{
28512851
name: 'ThirdPartyLazyComponent',
28522852
env: 'third-party',
@@ -2855,14 +2855,14 @@ describe('ReactFlight', () => {
28552855
stack: ' in myLazy (at **)\n in lazyInitializer (at **)',
28562856
props: {},
28572857
},
2858-
{time: 16},
2858+
{time: 17},
28592859
]
28602860
: undefined,
28612861
);
28622862
expect(getDebugInfo(thirdPartyChildren[2])).toEqual(
28632863
__DEV__
28642864
? [
2865-
{time: 11},
2865+
{time: 12},
28662866
{
28672867
name: 'ThirdPartyFragmentComponent',
28682868
env: 'third-party',
@@ -2871,7 +2871,7 @@ describe('ReactFlight', () => {
28712871
stack: ' in Object.<anonymous> (at **)',
28722872
props: {},
28732873
},
2874-
{time: 12},
2874+
{time: 13},
28752875
]
28762876
: undefined,
28772877
);
@@ -2936,7 +2936,7 @@ describe('ReactFlight', () => {
29362936
expect(getDebugInfo(promise)).toEqual(
29372937
__DEV__
29382938
? [
2939-
{time: 14},
2939+
{time: 16},
29402940
{
29412941
name: 'ServerComponent',
29422942
env: 'Server',
@@ -2947,7 +2947,7 @@ describe('ReactFlight', () => {
29472947
transport: expect.arrayContaining([]),
29482948
},
29492949
},
2950-
{time: 15},
2950+
{time: 17},
29512951
]
29522952
: undefined,
29532953
);
@@ -2956,7 +2956,7 @@ describe('ReactFlight', () => {
29562956
expect(getDebugInfo(thirdPartyFragment)).toEqual(
29572957
__DEV__
29582958
? [
2959-
{time: 16},
2959+
{time: 18},
29602960
{
29612961
name: 'Keyed',
29622962
env: 'Server',
@@ -2967,15 +2967,15 @@ describe('ReactFlight', () => {
29672967
children: {},
29682968
},
29692969
},
2970-
{time: 17},
2970+
{time: 19},
29712971
]
29722972
: undefined,
29732973
);
29742974
// We expect the debug info to be transferred from the inner stream to the outer.
29752975
expect(getDebugInfo(thirdPartyFragment.props.children)).toEqual(
29762976
__DEV__
29772977
? [
2978-
{time: 11},
2978+
{time: 12},
29792979
{
29802980
name: 'ThirdPartyAsyncIterableComponent',
29812981
env: 'third-party',
@@ -2984,7 +2984,7 @@ describe('ReactFlight', () => {
29842984
stack: ' in Object.<anonymous> (at **)',
29852985
props: {},
29862986
},
2987-
{time: 12},
2987+
{time: 13},
29882988
]
29892989
: undefined,
29902990
);
@@ -3132,7 +3132,7 @@ describe('ReactFlight', () => {
31323132
expect(getDebugInfo(greeting)).toEqual(
31333133
__DEV__
31343134
? [
3135-
{time: 11},
3135+
{time: 12},
31363136
{
31373137
name: 'Component',
31383138
env: 'A',
@@ -3144,7 +3144,7 @@ describe('ReactFlight', () => {
31443144
{
31453145
env: 'B',
31463146
},
3147-
{time: 12},
3147+
{time: 13},
31483148
]
31493149
: undefined,
31503150
);
@@ -3332,9 +3332,9 @@ describe('ReactFlight', () => {
33323332
},
33333333
};
33343334
expect(getDebugInfo(greeting)).toEqual([
3335-
{time: 11},
3336-
greetInfo,
33373335
{time: 12},
3336+
greetInfo,
3337+
{time: 13},
33383338
{
33393339
name: 'Container',
33403340
env: 'Server',
@@ -3350,7 +3350,7 @@ describe('ReactFlight', () => {
33503350
}),
33513351
},
33523352
},
3353-
{time: 13},
3353+
{time: 14},
33543354
]);
33553355
// The owner that created the span was the outer server component.
33563356
// We expect the debug info to be referentially equal to the owner.

packages/react-reconciler/src/ReactFiberWorkLoop.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ import {
4949
enableViewTransition,
5050
enableSwipeTransition,
5151
} from 'shared/ReactFeatureFlags';
52-
import {
53-
startResettingOwnerStackLimit,
54-
stopResettingOwnerStackLimit,
55-
} from 'shared/ReactOwnerStackReset';
52+
import {resetOwnerStackLimit} from 'shared/ReactOwnerStackReset';
5653
import ReactSharedInternals from 'shared/ReactSharedInternals';
5754
import is from 'shared/objectIs';
5855

@@ -1324,10 +1321,6 @@ function finishConcurrentRender(
13241321
}
13251322
}
13261323

1327-
if (__DEV__) {
1328-
stopResettingOwnerStackLimit();
1329-
}
1330-
13311324
if (shouldForceFlushFallbacksInDEV()) {
13321325
// We're inside an `act` scope. Commit immediately.
13331326
commitRoot(
@@ -1992,7 +1985,7 @@ function prepareFreshStack(root: FiberRoot, lanes: Lanes): Fiber {
19921985
finishQueueingConcurrentUpdates();
19931986

19941987
if (__DEV__) {
1995-
startResettingOwnerStackLimit();
1988+
resetOwnerStackLimit();
19961989

19971990
ReactStrictModeWarnings.discardPendingWarnings();
19981991
}

0 commit comments

Comments
 (0)