@ethlete/query 5.32.1 → 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,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 5.32.1
|
|
4
10
|
|
|
5
11
|
### Patch 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.
|
|
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) => {
|