Skip to content

Commit ae87aca

Browse files
author
Sebastian Silbermann
committed
WIP
1 parent 16ee439 commit ae87aca

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

packages/react-reconciler/src/ReactFiberLane.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,18 +905,21 @@ export function addFiberToLanesMap(
905905
}
906906
}
907907

908-
export function movePendingFibersToMemoized(root: FiberRoot, lanes: Lanes) {
908+
export function movePendingFibersToMemoized(root: FiberRoot, passedLanes) {
909+
console.log('movePendingFibersToMemoized', root, new Error().stack);
909910
if (!enableUpdaterTracking) {
910911
return;
911912
}
912913
if (!isDevToolsPresent) {
913914
return;
914915
}
916+
let lanes = root.pendingLanes;
915917
const pendingUpdatersLaneMap = root.pendingUpdatersLaneMap;
916918
const memoizedUpdaters = root.memoizedUpdaters;
917919
while (lanes > 0) {
918920
const index = laneToIndex(lanes);
919921
const lane = 1 << index;
922+
console.log({index, lane, passedLanes});
920923

921924
const updaters = pendingUpdatersLaneMap[index];
922925
if (updaters.size > 0) {
@@ -931,6 +934,7 @@ export function movePendingFibersToMemoized(root: FiberRoot, lanes: Lanes) {
931934

932935
lanes &= ~lane;
933936
}
937+
console.log('moved');
934938
}
935939

936940
export function addTransitionToLanesMap(

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ export function isUnsafeClassRenderPhaseUpdate(fiber: Fiber): boolean {
910910
export function performConcurrentWorkOnRoot(
911911
root: FiberRoot,
912912
didTimeout: boolean,
913+
passedLanes,
913914
): RenderTaskFn | null {
914915
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
915916
resetNestedUpdateFlag();
@@ -947,6 +948,7 @@ export function performConcurrentWorkOnRoot(
947948
// Defensive coding. This is never expected to happen.
948949
return null;
949950
}
951+
console.log({lanes, passedLanes});
950952

951953
// We disable time-slicing in some cases: if the work has been CPU-bound
952954
// for too long ("expired" work, to prevent starvation), or we're in

packages/react-reconciler/src/__tests__/ReactUpdaters-test.internal.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('updaters', () => {
4545
}
4646
const schedulerTags = [];
4747
const schedulerTypes = [];
48+
console.log(fiberRoot.pendingUpdatersLaneMap);
4849
fiberRoot.memoizedUpdaters.forEach(fiber => {
4950
schedulerTags.push(fiber.tag);
5051
schedulerTypes.push(fiber.elementType);
@@ -262,7 +263,7 @@ describe('updaters', () => {
262263
await waitForAll([]);
263264
});
264265

265-
it('should cover suspense pings', async () => {
266+
it.only('should cover suspense pings', async () => {
266267
let data = null;
267268
let resolver = null;
268269
let promise = null;
@@ -304,19 +305,19 @@ describe('updaters', () => {
304305
expect(setShouldSuspend).not.toBeNull();
305306
expect(allSchedulerTypes).toEqual([[null]]);
306307

308+
console.log('suspend -----------------');
307309
await act(() => {
308310
setShouldSuspend(true);
309311
});
310312
assertLog(['onCommitRoot']);
311313
expect(allSchedulerTypes).toEqual([[null], [Suspender]]);
312314

313315
expect(resolver).not.toBeNull();
314-
await act(() => {
315-
resolver('abc');
316-
return promise;
317-
});
318-
assertLog(['onCommitRoot']);
319-
expect(allSchedulerTypes).toEqual([[null], [Suspender], []]);
316+
console.log('final -----------------');
317+
resolver('abc');
318+
await waitForAll(['onCommitRoot']);
319+
320+
expect(allSchedulerTypes).toEqual([[null], [Suspender], [Suspender]]);
320321

321322
// Verify no outstanding flushes
322323
await waitForAll([]);

0 commit comments

Comments
 (0)