perf(query-cache): invalidate namespaces in parallel (Q-6.3-8)
TanStack 5 invalidateQueries resolves only after the active refetches finish. The coordinator awaited each namespace in a for loop, so one invalidation (and lease.release(), which waits on it) took the sum of every namespace's refetch time. The namespaces now run through Promise.allSettled; each rejected one is still reported once as "invalidate". Verified: new test holds the first namespace's refetch open and failed RED (second invalidateQueries never started); it now passes and checks that a failure is reported once. All lane gates pass except the known removal-fixture test; provider-guardian-transaction timed out once under load and passed on rerun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c7052ef09a
commit
fcd37a9d16
@@ -76,16 +76,19 @@ export function createTanStackCacheCoordinator(
|
||||
namespaces.set(queryNamespaceIdentityKey(namespace), namespace);
|
||||
}
|
||||
}
|
||||
for (const namespace of namespaces.values()) {
|
||||
try {
|
||||
await dependencies.queryClient.invalidateQueries({
|
||||
// Q-6.3-8. invalidateQueries resolves only after the active refetches
|
||||
// finish, so the namespaces run side by side instead of one after another.
|
||||
const results = await Promise.allSettled(
|
||||
[...namespaces.values()].map(async (namespace) =>
|
||||
dependencies.queryClient.invalidateQueries({
|
||||
queryKey: createQueryInvalidationPrefix(namespace),
|
||||
exact: false,
|
||||
refetchType: "active",
|
||||
});
|
||||
} catch {
|
||||
report("invalidate");
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
for (const result of results) {
|
||||
if (result.status === "rejected") report("invalidate");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user