@ethlete/query 5.32.0 → 5.32.2

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,17 @@
1
1
  # @ethlete/query
2
2
 
3
+ ## 5.32.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9c72658`](https://github.com/ethlete-io/ethdk/commit/9c72658eb6a748d2ee7d04e6e06c38a70247ed7f) Thanks [@TomTomB](https://github.com/TomTomB)! - Always retry queries if they error due to being offline
8
+
9
+ ## 5.32.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`a59d9f4`](https://github.com/ethlete-io/ethdk/commit/a59d9f4ed95b5fa6471a69e0052399fddac57153) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix queries with route functions not getting auto executed
14
+
3
15
  ## 5.32.0
4
16
 
5
17
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  import * as i1 from '@ethlete/core';
2
- import { createDestroy, computedTillTruthy, syncSignal, getCookie, setCookie, deleteCookie, DelayableDirective, nextFrame, RuntimeError, isObject, injectRoute, getDomain, previousSignalValue, injectQueryParamChanges, injectQueryParams, clone, equal, ET_PROPERTY_REMOVED } from '@ethlete/core';
2
+ import { createDestroy, computedTillTruthy, syncSignal, getCookie, setCookie, deleteCookie, DelayableDirective, nextFrame, RuntimeError, isObject, injectRoute, getDomain, clamp, previousSignalValue, injectQueryParamChanges, injectQueryParams, clone, equal, ET_PROPERTY_REMOVED } from '@ethlete/core';
3
3
  import { Observable, takeUntil, startWith, pairwise, tap, switchMap, of, BehaviorSubject, Subject, fromEvent, timer, take, filter, takeWhile, map, shareReplay, ReplaySubject, combineLatest, interval, skip, withLatestFrom, debounceTime, Subscription, retry, throwError, catchError, merge } from 'rxjs';
4
4
  import { HttpStatusCode, HttpErrorResponse, HttpEventType, HttpClient, HttpHeaders } from '@angular/common/http';
5
5
  import * as i0 from '@angular/core';
@@ -3035,7 +3035,7 @@ const createBearerAuthProvider = (options) => {
3035
3035
  const isCookieEnabled = cookieEnabled();
3036
3036
  const res = latestExecutedQuery();
3037
3037
  const error = res?.query?.query.error();
3038
- if (!isCookieEnabled || (error && error.raw.status === 401)) {
3038
+ if (!isCookieEnabled || (error && error.code === 401)) {
3039
3039
  deleteCookie$1();
3040
3040
  return;
3041
3041
  }
@@ -3329,14 +3329,22 @@ const extractExpiresInSeconds = (headers) => {
3329
3329
  const shouldRetryRequest = (options) => {
3330
3330
  const normalizedOptions = options instanceof HttpErrorResponse ? { retryCount: 0, error: options } : options;
3331
3331
  const { retryCount, error } = normalizedOptions;
3332
- const defaultRetryDelay = 1000 + 1000 * retryCount;
3332
+ const defaultRetryDelay = clamp(1000 + 1000 * retryCount, 1000, 5000);
3333
+ const { status, error: detail, headers } = error;
3334
+ // Code 0 usually means the internet connection is down. We retry in this case.
3335
+ // It could also be a CORS issue but that should not be the case in production.
3336
+ // We will retry in this case until the connection is back.
3337
+ if (status === 0) {
3338
+ return { retry: true, delay: defaultRetryDelay };
3339
+ }
3340
+ // Don't retry if we already retried 3 times
3333
3341
  if (retryCount > 3) {
3334
3342
  return { retry: false };
3335
3343
  }
3344
+ // Don't retry if it's not an http error
3336
3345
  if (!(error instanceof HttpErrorResponse)) {
3337
3346
  return { retry: false };
3338
3347
  }
3339
- const { status, error: detail, headers } = error;
3340
3348
  // Retry on 5xx errors (except 500 internal server error since those are usually not recoverable)
3341
3349
  if (status >= 501) {
3342
3350
  // Don't retry if a requested page is out of range
@@ -3358,11 +3366,6 @@ const shouldRetryRequest = (options) => {
3358
3366
  }
3359
3367
  return { retry: true, delay: defaultRetryDelay };
3360
3368
  }
3361
- // Code 0 usually means the internet connection is down. We retry in this case.
3362
- // It could also be a CORS issue but that should not be the case in production.
3363
- if (status === 0) {
3364
- return { retry: true, delay: defaultRetryDelay };
3365
- }
3366
3369
  return { retry: false };
3367
3370
  };
3368
3371
  const getQueryFeatureUsage = (options) => {
@@ -3373,7 +3376,7 @@ const getQueryFeatureUsage = (options) => {
3373
3376
  : shouldAutoExecuteQuery(options.creatorInternals.method);
3374
3377
  const hasRouteFunction = typeof creatorInternals?.route === 'function' ||
3375
3378
  typeof creator?.route === 'function';
3376
- const shouldAutoExecute = shouldAutoExecuteMethod && !queryConfig.onlyManualExecution && !hasRouteFunction;
3379
+ const shouldAutoExecute = shouldAutoExecuteMethod && !queryConfig.onlyManualExecution;
3377
3380
  if (hasRouteFunction && !hasWithArgsFeature && !queryConfig.silenceMissingWithArgsFeatureError) {
3378
3381
  throw withArgsQueryFeatureMissingButRouteIsFunction();
3379
3382
  }