@ethlete/query 6.0.0-next.13 → 6.0.0-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @ethlete/query
2
2
 
3
+ ## 6.0.0-next.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#3019](https://github.com/ethlete-io/ethdk/pull/3019) [`b5655a9`](https://github.com/ethlete-io/ethdk/commit/b5655a9124b2ffc4d6982ca20be360b227a37107) Thanks [@github-actions](https://github.com/apps/github-actions)! - Query cache: a cached request now correctly becomes stale once its freshness
8
+ window (from `cache-control` / `expires`) elapses, so `execute({ allowCache: true })`
9
+ refetches instead of serving the cached response forever.
10
+
3
11
  ## 6.0.0-next.13
4
12
 
5
13
  ### Patch Changes
@@ -1576,11 +1576,14 @@ const createHttpRequest = (options) => {
1576
1576
  ...(ngDevMode ? [{ debugName: "lastExecuteTime" }] : /* istanbul ignore next */ []));
1577
1577
  const expiresIn = signal(null, /* @ts-ignore */
1578
1578
  ...(ngDevMode ? [{ debugName: "expiresIn" }] : /* istanbul ignore next */ []));
1579
- const isStale = computed(() => {
1579
+ // NOTE: This must be a plain function, not a `computed`. The freshness check compares against
1580
+ // `Date.now()`, which is not reactive, so a memoized computed would only ever recompute when
1581
+ // `expiresIn` changes — once it evaluated to `false` (fresh) it would stay `false` forever, even
1582
+ // after the window elapsed, turning every `allowCache` execute into a permanent cache hit.
1583
+ const isStale = () => {
1580
1584
  const expiresInTs = expiresIn();
1581
1585
  return expiresInTs === null || expiresInTs < Date.now();
1582
- }, /* @ts-ignore */
1583
- ...(ngDevMode ? [{ debugName: "isStale" }] : /* istanbul ignore next */ []));
1586
+ };
1584
1587
  const createStream = () => {
1585
1588
  const headers = typeof args?.headers === 'function' ? args.headers() : args?.headers;
1586
1589
  return dependencies.httpClient