Skip to content

fix: chunk fetchStatusByIds and updateAllUsersSince requests (MM-68226)#9669

Open
ewwollesen wants to merge 3 commits intomainfrom
fix/chunk-large-user-requests
Open

fix: chunk fetchStatusByIds and updateAllUsersSince requests (MM-68226)#9669
ewwollesen wants to merge 3 commits intomainfrom
fix/chunk-large-user-requests

Conversation

@ewwollesen
Copy link
Copy Markdown

Problem

On large teams fetchStatusByIds and updateAllUsersSince send all user IDs in a single POST body. This can exceed the server's MaximumPayloadSizeBytes. This can cause the app to return "Request body too large" on every app launch and WebSocket reconnect, breaking team switching entirely.

Solution

Fix (2 files, +8 / -2 lines)

  1. app/constants/general.ts — Added MAX_IDS_PER_STATUS_REQUEST: 200 and MAX_IDS_PER_PROFILES_REQUEST: 100 (matching web client batch sizes)
  2. app/actions/remote/user.ts:
    - fetchStatusByIds (line 366-368): Chunks userIds into batches of 200 before calling client.getStatusesByIds(), runs in parallel via Promise.all, flattens results
    - updateAllUsersSince (line 658-660): Chunks userIds into batches of 100 before calling client.getProfilesByIds(), same parallel + flatten pattern

The chunk utility from lodash was already imported. Existing tests pass unchanged since they use small ID arrays (single chunk).

… 413 errors

On servers with large teams (thousands of members), the mobile client
sends all user IDs in a single POST body for status and profile-by-ID
requests. This exceeds the server's MaximumPayloadSizeBytes limit
(default 300KB, often configured lower), causing "Request body too
large" errors on every app launch and websocket reconnect.

Chunk these requests into batches (200 IDs for statuses, 100 for
profiles) matching the web client's batching strategy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mm-cloud-bot mm-cloud-bot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 8, 2026
@mm-cloud-bot
Copy link
Copy Markdown

@ewwollesen: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

I understand the commands that are listed here

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

Two remote action functions were updated to split large ID lists into configured chunk sizes and fetch each chunk concurrently using Promise.allSettled, then flatten only fulfilled results before continuing with existing persistence logic. Two new constants define the chunk sizes.

Changes

Cohort / File(s) Summary
Configuration Constants
app/constants/general.ts
Added MAX_IDS_PER_STATUS_REQUEST = 200 and MAX_IDS_PER_PROFILES_REQUEST = 100 to the exported defaults.
Chunked Parallel Fetching
app/actions/remote/user.ts
Replaced single large client.getStatusesByIds(userIds) and client.getProfilesByIds(userIds, {since}, groupLabel) calls with chunked requests using the new constants; batches are fetched via Promise.allSettled and only fulfilled results are flattened into statuses / userUpdates before existing batching/persistence.

Sequence Diagram(s)

sequenceDiagram
    participant RemoteAction as RemoteAction (user.ts)
    participant Config as Config (general.ts)
    participant Client as Client API
    participant Store as Persistence

    RemoteAction->>Config: read MAX_IDS_PER_* constants
    RemoteAction->>RemoteAction: split userIds into batches
    RemoteAction->>Client: send concurrent requests for each batch (allSettled)
    Client-->>RemoteAction: return settled results (fulfilled/rejected)
    RemoteAction->>RemoteAction: filter fulfilled, flatten results
    RemoteAction->>Store: continue with existing batching/persistence
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining both the problem and the solution with specific file and line references.
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: implementing request chunking for fetchStatusByIds and updateAllUsersSince to resolve server payload size issues.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/chunk-large-user-requests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Coverage Comparison Report

Generated on April 08, 2026 at 18:41:53 UTC

+-----------------+------------+------------+-----------+
| Metric          | Main       | This PR    | Diff      |
+-----------------+------------+------------+-----------+
| Lines           |     85.13% |     85.14% |     0.01% |
| Statements      |     85.00% |     85.00% |     0.00% |
| Branches        |     72.07% |     72.06% |    -0.01% |
| Functions       |     83.91% |     83.93% |     0.02% |
+-----------------+------------+------------+-----------+
| Total           |     81.52% |     81.53% |     0.01% |
+-----------------+------------+------------+-----------+

Rename `ids` to `batchIds` in chunk map callbacks to avoid shadowing
the module-level `ids` variable used by `debouncedFetchStatusesByIds`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ewwollesen
Copy link
Copy Markdown
Author

Comment thread app/actions/remote/user.ts Outdated
Comment thread app/actions/remote/user.ts Outdated
… all results

Per review feedback — if one batch request fails, the remaining
successful batches are still used instead of throwing away everything.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ewwollesen ewwollesen changed the title fix: chunk fetchStatusByIds and updateAllUsersSince requests to avoid… fix: chunk fetchStatusByIds and updateAllUsersSince requests (MM-68226) Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/release-note-label-needed kind/bug Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants