Page MenuHomePhabricator

[lib] Use useDerivedObject to reduce renders due to preRequestUserState
ClosedPublic

Authored by ashoat on Apr 12 2024, 2:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 12:34 AM
Unknown Object (File)
Wed, Nov 6, 8:52 AM
Unknown Object (File)
Thu, Oct 17, 2:11 PM
Unknown Object (File)
Thu, Oct 17, 2:10 PM
Unknown Object (File)
Thu, Oct 17, 2:10 PM
Unknown Object (File)
Thu, Oct 17, 2:10 PM
Unknown Object (File)
Oct 2 2024, 7:57 AM
Unknown Object (File)
Sep 6 2024, 5:45 AM
Subscribers

Details

Summary

While working on ENG-7385, I did some investigation to see why performAuth was getting regenerated. It turned out that it was largely due to preRequestUserState being regenerated.

It's hard to properly memoize this, since we need to memoize N pieces of data for each entry in an object. Neither createSelector nor useMemo can handle an unbounded list of data.

I introduced useDerivedObject in D10465 to solve precisely this problem. By integrating it here (in addition to the preceding diff) I was able to solve the issue of performAuth being cancelled during initial keyserverAuth following new user registration.

Depends on D11655

Test Plan
  1. I added logs for when the performAuth got cancelled and restarted
  2. I ran through the new registration flow
  3. I confirmed that when the registration button was pressed, I no longer saw any logs about performAuth getting cancelled and restarted, and that we were no longer wasting an unnecessary amount of one-time keys

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/selectors/account-selectors.js
82 ↗(On Diff #39094)

I guess I missed Info in this name, but it's already quite long

I wonder if I should rename it to something shorter...

This revision is now accepted and ready to land.Apr 15 2024, 1:00 AM