Skip to content

fix(client): batch fetchUsers contact lookups in chunks of 100 - #259

Merged
nakasyou merged 1 commit into
evex-dev:mainfrom
tokuzou0829:fix/client-fetch-users-batch
Nov 4, 2026
Merged

nakasyou merged 1 commit into
evex-dev:mainfrom
tokuzou0829:fix/client-fetch-users-batch

Conversation

@tokuzou0829

Copy link
Copy Markdown
Contributor

Description

Client.fetchUsers() (and therefore line contacts list) fails on accounts with more than 100 friends:

getContactsV3(/RE4) -> {"ere":{"max_size":100}}

Cause

fetchUsers() passes every mid from getUserFriendIds to a single getContactsV3 call, 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

  • Split userFriendMids into batches of at most 100 and call getContactsV3 once per batch, merging the results in order.
  • Batch the getContactsV2 fallback the same way, since it takes the same mid list.
  • The fallback chain (V3 → V2 → per-user getUser, gated by isApiNotCapable) is unchanged, and behavior for ≤100 friends is identical (a single request).

Tests

  • Added tests in 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-user getUser fallback 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 on main in my environment because of network restrictions.
  • Real account with 182 friends: the released CLI fails with max_size: 100; pnpm line contacts list --json from this branch returns all 182 contacts. (Read-only; no messages sent.)

Checklist

  • Run tests (optional)
  • Add jsdoc (optional)
  • Test in your environment (optional)

@nakasyou
nakasyou merged commit 4ae7894 into evex-dev:main Nov 4, 2026
1 check passed
frankekn pushed a commit to frankekn/linejs that referenced this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants