Where
src/primitives/createLazyLoadQuery.ts, inside the cacheEntry memo — L129 (the check) and L133-143 (the switch that consumes it).
// L129-131
const queryAvailablility = environment().check(operation);
const queryStatus = queryAvailablility.status;
const hasFullQuery = queryStatus === "available";
// L133-143 — hasFullQuery is read at exactly ONE place: the store-or-network arm
const shouldFetch = (() => {
switch (fetchPolicy()) {
case "store-only": return false;
case "store-or-network": return !hasFullQuery; // <- only consumer
case "store-and-network":
case "network-only": return true;
}
})();
What happens
environment.check(operation) — a full store-availability traversal — runs unconditionally, but hasFullQuery is consumed only in the store-or-network branch. For network-only, shouldFetch is unconditionally true, so the check result is dead.
Why it matters
Small but real: one store traversal per cache-miss under network-only, discarded. Not a per-render hot path (the memo early-returns on a cache hit, L126-127), but pure waste under that policy.
Proposal
Compute the check only when a policy actually needs it:
const policy = fetchPolicy();
const hasFullQuery =
policy === "network-only" ? false : environment().check(operation).status === "available";
I have this ready as a PR — the change plus a test asserting check is skipped for network-only — and I'll open it if the direction looks right.
Costs / risks
Behavior-preserving as scoped. Deliberately skips only network-only: store-or-network needs the result, and store-only / store-and-network render from the store and may rely on check()'s incidental missing-field restore side effect — so those keep calling it. (Skipping the check for those too is possible but would drop that restore write, so it is left out.)
Alternative
Leave as-is — the cost is a single traversal per network-only cache-miss, so this is a minor optimization, not a correctness fix. Reasonable to decline if the added branch isn't worth it.
References
Test asserts environment.check is not called for network-only and is called for store-or-network. (A sibling finding in the same file — a non-live query's in-flight request not being cancelled on unmount — will follow as a separate issue.)
About this issue
Drafted by Shiro (Claude Opus 4.8), an AI assistant working with @nyanrus. If check() has a side effect I've overlooked that network-only relies on, please correct me — that would change the conclusion.
Where
src/primitives/createLazyLoadQuery.ts, inside thecacheEntrymemo — L129 (the check) and L133-143 (the switch that consumes it).What happens
environment.check(operation)— a full store-availability traversal — runs unconditionally, buthasFullQueryis consumed only in thestore-or-networkbranch. Fornetwork-only,shouldFetchis unconditionallytrue, so the check result is dead.Why it matters
Small but real: one store traversal per cache-miss under
network-only, discarded. Not a per-render hot path (the memo early-returns on a cache hit, L126-127), but pure waste under that policy.Proposal
Compute the check only when a policy actually needs it:
I have this ready as a PR — the change plus a test asserting
checkis skipped for network-only — and I'll open it if the direction looks right.Costs / risks
Behavior-preserving as scoped. Deliberately skips only
network-only:store-or-networkneeds the result, andstore-only/store-and-networkrender from the store and may rely oncheck()'s incidental missing-field restore side effect — so those keep calling it. (Skipping the check for those too is possible but would drop that restore write, so it is left out.)Alternative
Leave as-is — the cost is a single traversal per network-only cache-miss, so this is a minor optimization, not a correctness fix. Reasonable to decline if the added branch isn't worth it.
References
Test asserts
environment.checkis not called fornetwork-onlyand is called forstore-or-network. (A sibling finding in the same file — a non-live query's in-flight request not being cancelled on unmount — will follow as a separate issue.)About this issue
Drafted by Shiro (Claude Opus 4.8), an AI assistant working with @nyanrus. If
check()has a side effect I've overlooked that network-only relies on, please correct me — that would change the conclusion.