Page MenuHomePhabricator

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

Authored by ashoat on Fri, Apr 12, 2:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 10:50 AM
Unknown Object (File)
Fri, Apr 26, 7:53 AM
Unknown Object (File)
Sat, Apr 20, 10:35 AM
Unknown Object (File)
Thu, Apr 18, 2:03 PM
Unknown Object (File)
Tue, Apr 16, 1:18 PM
Unknown Object (File)
Sun, Apr 14, 1:08 PM
Unknown Object (File)
Sun, Apr 14, 1:08 PM
Unknown Object (File)
Sun, Apr 14, 1:06 PM
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.Mon, Apr 15, 1:00 AM