Version
@netscript/sdk@0.0.5 published docs and implementation.
Problem
The published service SDK example says:
const entry = await api.orders.list.getCachedEntry({ limit: 20 });
if (entry) return entry; // serve cached; SDK reloads stale in the background
That comment is false for 0.0.5. actionMethod.getCachedEntry() delegates directly to the provider, and CacheQuery#getCachedEntry() only reads the store and converts its timestamp. It does not evaluate staleTime, call queryFn, or schedule revalidation. A loader following the documented fast path can therefore serve stale data until cacheTime expiry (300 seconds by default).
Minimal reproduction
const cache = new CacheQuery(memoryStore);
let calls = 0;
await cache.query(['orders', 'list', '{}'], {
staleTime: 1,
cacheTime: 60_000,
queryFn: async () => ({ value: ++calls }),
});
await new Promise((resolve) => setTimeout(resolve, 5));
const stale = await cache.getCachedEntry<{ value: number }>(['orders', 'list', '{}']);
await Promise.resolve();
console.log(stale?.data.value); // 1
console.log(calls); // 1: no foreground/background refresh
Related: the current background revalidation path bypasses the inflight-request map, so concurrent stale SWR readers can also duplicate refreshes.
Expected
Either correct the documentation to require a cache-aware query() before reading metadata, or add a queryEntry()/revalidating-entry API that applies the declared stale policy while returning { data, cachedAt }.
Acceptance
Version
@netscript/sdk@0.0.5published docs and implementation.Problem
The published service SDK example says:
That comment is false for 0.0.5.
actionMethod.getCachedEntry()delegates directly to the provider, andCacheQuery#getCachedEntry()only reads the store and converts its timestamp. It does not evaluatestaleTime, callqueryFn, or schedule revalidation. A loader following the documented fast path can therefore serve stale data untilcacheTimeexpiry (300 seconds by default).Minimal reproduction
Related: the current background revalidation path bypasses the inflight-request map, so concurrent stale SWR readers can also duplicate refreshes.
Expected
Either correct the documentation to require a cache-aware
query()before reading metadata, or add aqueryEntry()/revalidating-entry API that applies the declared stale policy while returning{ data, cachedAt }.Acceptance
cachedAtreflects the refreshed value.