Skip to content

A burst of graph events refetches the graph once, not once per event - #263

Merged
WaylandYang merged 2 commits into
devfrom
fix/graph-refetches-once-per-burst
Sep 3, 2026
Merged

WaylandYang merged 2 commits into
devfrom
fix/graph-refetches-once-per-burst

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

Symptom

While documents are being extracted, the graph page refetches graph/overview over and over. Right after uploading three short documents to a fresh base, the network panel showed 16 identical overview requests within a couple of seconds. Each extracted fact emits a graph event, and useKbEvents invalidated the query on every one of them.

Change

useKbEvents no longer invalidates on each event. It records the affected query keys and flushes them once the stream has been quiet for 300 ms, so a burst of events costs one refetch, and that refetch necessarily includes every change in the burst. Idempotence is unchanged; only the cadence is. On unmount the pending keys are flushed rather than dropped, so coming back to a page still shows fresh data.

Verification

A/B on the same backend with both frontends open on the graph page of the same base, then one document uploaded:

overview requests after the upload
dev 8 (two bursts of 4, at ~25 s and ~57 s)
this branch 4 (each burst collapsed to the document event and the graph events that followed two seconds later)

A cold load of the graph page still issues exactly one request. pnpm build passes.

No issue was filed for this; it was noticed while testing #259.

🤖 Generated with Claude Code

@WaylandYang
WaylandYang merged commit 75e63bf into dev Sep 3, 2026
@WaylandYang
WaylandYang deleted the fix/graph-refetches-once-per-burst branch September 3, 2026 10:49
@WaylandYang WaylandYang mentioned this pull request Sep 3, 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.

1 participant