fix(desktop): preserve membership refresh during an in-flight channel fetch - #7306
nathansmithopenclaw-alt wants to merge 2 commits into
Conversation
Signed-off-by: nathansmithopenclaw-alt <273889179+nathansmithopenclaw-alt@users.noreply.github.com>
🔐 Codex Security Review
|
Chessing234
left a comment
There was a problem hiding this comment.
deferring the list invalidate while get_channels is in flight (and re-arming) is exactly the membership/list race. test covers the busy→idle handoff.
Chessing234
left a comment
There was a problem hiding this comment.
the idle helper is the right idea, but isFetching({ queryKey: channelsQueryKey }) is a prefix match, and this handler also kicks detail/members first — so those child fetches keep the gate closed and delay the list refresh even when get_channels is idle. please use exact: true for the list query (and cover that in the test without wall-clock sleeps).
`isFetching({ queryKey: channelsQueryKey })` matches by prefix, so an
in-flight ["channels", id, "detail"] or ["channels", id, "members"] fetch
counted as the channel list being busy. The membership handler kicks both
of those immediately after arming the debounce, so the gate was held
closed by the very fetches the handler itself started and re-armed
indefinitely under membership churn. Pass `exact: true` so only
get_channels holds the gate.
Drive the test against a real QueryClient instead of replacing
`isFetching` wholesale: a stub cannot exercise prefix-vs-exact filter
semantics, which is the behaviour at issue. Time is driven by node:test
fake timers, so the file no longer sleeps on the wall clock.
Signed-off-by: nathansmithopenclaw-alt <273889179+nathansmithopenclaw-alt@users.noreply.github.com>
|
Good catch — fixed in |
Summary
Keep the Desktop joined-channel list live when a membership notification
arrives while
get_channelsis already in flight.44100/44101channel-list invalidation through the existingrefreshChannelsWhenIdlehelper.after it becomes idle.
Problem
useMembershipNotificationscurrently invalidateschannelsQueryKeyimmediately. If an older
get_channelsrequest is already running, themembership signal can lose this ordering:
get_channelsstarts and reads the pre-membership list.44100or44101arrives and invalidates the query.browse, or reconnect refresh.
The repository already documents and solves this race for ordinary live
channel traffic in
refreshChannelsWhenIdle. This change applies the sameboundary to membership-driven discovery.
Scope
This is intentionally client-only and narrow. It does not:
39002subscription (those discovery events arechannel-scoped);
CLOSEDretry policy;User impact
When another member adds or removes the signed-in user, the Desktop channel
navigation converges immediately after any already-running channel fetch
settles instead of remaining stale for up to the next one-minute poll. The same
shared cache update also refreshes downstream channel-bound subscriptions,
search/reference resolution, unread state, and navigation labels.
Testing
one active fetch; prove channel detail and member-list keys invalidate
immediately while the channel-list invalidation waits for idle, then
lands exactly once.
git diff --check.Related: #6713