Guard against contributors failing to load correctly #229
Reference in New Issue
Block a user
Delete Branch "bugfix/missing-contributor-crash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I don't know how I ended up there, but it seems like I had a bad contributor profile stored in my IndexedDB. In order for others not also having to manually delete the database for the app to work again, let's just guard against the situation.
Problem
A contributor whose IPFS profile has no
accountsarray causes@kredits/contracts'ContributorSerializer.deserializeto throw →Contributor.getByIdrejects → the contributor never entersthis.contributors→loadContributionFromDataattachescontributor: undefined→UserAvatarthrowsCannot read properties of undefined (reading 'github_uid')on render → the run-loop breaks andfetchMissingContributions/ subsequent contribution loading stalls, so no further contributions are loaded.Fix (app-side)
app/components/user-avatar/component.js: guard againstthis.contributorbeing undefined; addedcontributorto the computed's dependent keys so avatars re-render when a contributor is lazily loaded later.app/services/kredits.js—kreditsByContributor: filter out groups whose contributor isn't loaded instead of dereferencingundefined.totalKreditsEarned.app/services/kredits.js— newensureContributorLoaded(id): called fromloadContributionFromDataandloadReimbursementFromData; fire-and-forget background fetch of the missing contributor, deduped via acontributorsFetchingSet (added ininit) so a tight loop over many contributions for the same missing contributor doesn't hammer the RPC. Rejections are logged, never thrown, so the run loop can't be broken by a persistently broken profile. On success, dependent computeds (kreditsByContributor,UserAvatar) retrigger viacontributors.[].Tests
tests/integration/components/user-avatar/component-test.js: undefined contributor; contributor withoutgithub_uid.tests/unit/services/kredits-test.js:#kreditsByContributorwith an orphan contribution referencing a non-existent contributor id (asserts no throw and no orphan entry in the toplist).refs #224
Guard dashboard against contributors that fail to load from IPFSto Guard dashboard against contributors failing to load correctlyGuard dashboard against contributors failing to load correctlyto Guard against contributors failing to load correctly