-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DevTools: Fix "unknown" updater in profiler when a component unsuspends #28330
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,15 @@ describe('updaters', () => { | |
schedulerTags.push(fiber.tag); | ||
schedulerTypes.push(fiber.elementType); | ||
}); | ||
fiberRoot.pendingUpdatersLaneMap.forEach((pendingUpdaters, index) => { | ||
if (pendingUpdaters.size > 0) { | ||
// TODO: Is it ever ok to have dangling pending updaters or is this always a bug? | ||
// const lane = 1 << index; | ||
// throw new Error( | ||
// `Lane ${lane} has pending updaters. Either you didn't assert on all updates in your test or React is leaking updaters.`, | ||
// ); | ||
Comment on lines
+54
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests that currently would fail this: https://app.circleci.com/pipelines/github/facebook/react/54155/workflows/17c8ec84-c64b-4fc1-bde6-6fcb7532513e/jobs/892710 |
||
} | ||
}); | ||
allSchedulerTags.push(schedulerTags); | ||
allSchedulerTypes.push(schedulerTypes); | ||
}), | ||
|
@@ -266,9 +275,6 @@ describe('updaters', () => { | |
await waitForAll([]); | ||
}); | ||
|
||
// This test should be convertable to createRoot but the allScheduledTypes assertions are no longer the same | ||
// So I'm leaving it in legacy mode for now and just disabling if legacy mode is turned off | ||
// @gate !disableLegacyMode | ||
it('should cover suspense pings', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original issue in the test was that the updater was on the Default lane, the updater got pinged, and then we said we should render on a Retry lane ( |
||
let data = null; | ||
let resolver = null; | ||
|
@@ -303,10 +309,11 @@ describe('updaters', () => { | |
} | ||
}; | ||
|
||
const root = ReactDOMClient.createRoot(document.createElement('div')); | ||
await act(() => { | ||
ReactDOM.render(<Parent />, document.createElement('div')); | ||
assertLog(['onCommitRoot']); | ||
root.render(<Parent />); | ||
}); | ||
assertLog(['onCommitRoot']); | ||
expect(setShouldSuspend).not.toBeNull(); | ||
expect(allSchedulerTypes).toEqual([[null]]); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to investigate this further? Just transferring the updaters from
root.pingedLanes
toupdateLane
isn't enough. For some reason we're pinging whenroot.suspendedLanes & pingedLanes === NoLanes
. Which seems odd intuitively but maybe the bug isroot.suspendedLanes
having no overlap withpingedLanes
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe if we suspend on two Wakeables A and B, A gets pinged earlier, we unsuspend completely i.e. don't suspend on B again (e.g. conditional
use
?) and then we wouldn't want to retry when B gets pinged?Grasping for straws here since all tests still pass with this change.