starta.apiclient 1.112.8764 → 1.112.8780

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.
Files changed (2) hide show
  1. package/lib/request.js +16 -5
  2. package/package.json +1 -1
package/lib/request.js CHANGED
@@ -52,12 +52,23 @@ const requestFactory = (baseURL, middlewares) => {
52
52
  }
53
53
  catch (error) {
54
54
  const axiosError = error;
55
- if (((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) === 502 && retryCount > 0) {
56
- if (middlewares === null || middlewares === void 0 ? void 0 : middlewares.logger) {
57
- middlewares === null || middlewares === void 0 ? void 0 : middlewares.logger(`Retrying ${method} request to ${url} after 3 seconds due to 502 response`);
55
+ let retryDelay = null;
56
+ if (retryCount > 0) {
57
+ const isGoogleBot = () => {
58
+ const userAgent = navigator.userAgent.toLowerCase();
59
+ return /googlebot/i.test(userAgent);
60
+ };
61
+ if (((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) === 502) {
62
+ retryDelay = 3000;
58
63
  }
59
- yield delay(3000);
60
- return performRequestWithRetry(retryCount - 1);
64
+ else if ((axiosError === null || axiosError === void 0 ? void 0 : axiosError.message) === 'Network Error' &&
65
+ isGoogleBot()) {
66
+ retryDelay = 100;
67
+ }
68
+ }
69
+ if (retryDelay) {
70
+ yield delay(retryDelay);
71
+ return yield performRequestWithRetry(retryCount - 1);
61
72
  }
62
73
  else {
63
74
  return onErrorFactory(middlewares)(axiosError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starta.apiclient",
3
- "version": "1.112.8764",
3
+ "version": "1.112.8780",
4
4
  "main": "./lib/index.js",
5
5
  "description": "Wrapper for starta.one api",
6
6
  "author": "Collaboracia OÜ",