Repository navigation
fix(client): batch fetchUsers contact lookups in chunks of 100 - #259
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Client.fetchUsers()(and thereforeline contacts list) fails on accounts with more than 100 friends:Cause
fetchUsers()passes every mid fromgetUserFriendIdsto a singlegetContactsV3call, and the server caps one request at 100 mids. The error is not an "API not capable" error, so the V2 / per-user fallbacks are never reached and the whole call throws.Fix
userFriendMidsinto batches of at most 100 and callgetContactsV3once per batch, merging the results in order.getContactsV2fallback the same way, since it takes the same mid list.getUser, gated byisApiNotCapable) is unchanged, and behavior for ≤100 friends is identical (a single request).Tests
packages/linejs/client/fetch_users.test.ts: V3 and V2 with 100 / 101 / 250 friends (asserts request sizes[100],[100, 1],[100, 100, 50], ≤100 mids per request, and merged order), plus the per-usergetUserfallback with 101 friends.cd packages/linejs && pnpm exec tsc --noEmit: OK.pnpm exec vp check: no errors.cd packages/linejs && pnpm exec vp test: 342 passed; the only 2 failures are the live Google STUN probes (stun.test.ts,ice.test.ts), which also fail onmainin my environment because of network restrictions.max_size: 100;pnpm line contacts list --jsonfrom this branch returns all 182 contacts. (Read-only; no messages sent.)Checklist