fix(client): coalesce catalog refetches from event bursts - #47561
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.
A Desktop netlog showed
GET /api/mcpfetched 192 times in a 7 s window: 9–10 times per directory, median gap ~70 ms, for ~20 directories. The server emits onemcp.status.changedper MCP server as each one settles, andcreateDataanswered every event withinvalidate+sync, so a location with nine MCP servers cost nine identical refetches. Each of those also paid a CORS preflight, and together they tripped[server-request-queue] server thrashing detected.flowchart LR subgraph before [Before] E1[mcp.status.changed × N] --> R1[N × GET /api/mcp] end subgraph after [After] E2[mcp.status.changed × N] --> S[invalidate now, refetch after 150 ms quiet] --> R2[1 × GET /api/mcp] endChanges —
packages/client/src/solid/data.tssettle(key, load)invalidates immediately (so an explicitsync()during the window still reads fresh) and runs one refetch once the burst has been quiet forsettleMs = 150. Applied tomcp.status.changed, the only event the server emits once per member of a list.createSyncchains a reload behind an in-flight load when the key is invalidated mid-read. That reload has not read anything yet, so an invalidation arriving before it starts is already covered; marking it invalidated only chained a third, fourth, … load behind it.Pending.startednow gatesinvalidated, capping any burst at one in-flight load plus one queued reload for every key, not just MCP.Companion to #47443, which stops refetching catalogs for locations this client never read. This PR bounds the refetch rate for locations it did read.