@wix/wix-ui-icons-common 3.189.25 → 3.189.27

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.
@@ -24,6 +24,7 @@ __export(fetcher_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(fetcher_exports);
26
26
  const ABORT_SIGNAL_TIMEOUT = 5e3;
27
+ const isTransientError = (error) => error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
27
28
  function createTimeoutSignal(timeout) {
28
29
  if (typeof AbortSignal.timeout === "function") {
29
30
  return AbortSignal.timeout(timeout);
@@ -65,19 +66,30 @@ class IconContentFetcher {
65
66
  return "";
66
67
  }
67
68
  const url = `https://static.parastorage.com/services/wix-ui-icons-common/dist/icons/${theme}/${category}/${name}.${hash}.json`;
68
- const request = fetch(url, {
69
- signal: createTimeoutSignal(ABORT_SIGNAL_TIMEOUT)
70
- }).then((res) => {
71
- if (!res.ok) {
72
- throw new Error(`Failed to fetch icon: ${res.status}`);
69
+ const fetchContent = async (attemptsRemaining) => {
70
+ try {
71
+ const response = await fetch(url, {
72
+ signal: createTimeoutSignal(ABORT_SIGNAL_TIMEOUT)
73
+ });
74
+ if (!response.ok) {
75
+ throw new Error(`Failed to fetch icon: ${response.status}`);
76
+ }
77
+ return await response.json();
78
+ } catch (error) {
79
+ if (attemptsRemaining > 1 && isTransientError(error)) {
80
+ return fetchContent(attemptsRemaining - 1);
81
+ }
82
+ throw error;
73
83
  }
74
- return res.json();
75
- }).then((data) => {
84
+ };
85
+ const request = fetchContent(2).then((data) => {
76
86
  this.cache.set(cacheKey, data.content);
77
87
  this.pendingRequests.delete(cacheKey);
78
88
  }).catch((error) => {
79
89
  this.pendingRequests.delete(cacheKey);
80
- this.failedRequests.add(cacheKey);
90
+ if (!isTransientError(error)) {
91
+ this.failedRequests.add(cacheKey);
92
+ }
81
93
  console.error(`Error fetching icon ${name}:`, error);
82
94
  throw error;
83
95
  });
@@ -1,4 +1,5 @@
1
1
  const ABORT_SIGNAL_TIMEOUT = 5e3;
2
+ const isTransientError = (error) => error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
2
3
  function createTimeoutSignal(timeout) {
3
4
  if (typeof AbortSignal.timeout === "function") {
4
5
  return AbortSignal.timeout(timeout);
@@ -40,19 +41,30 @@ class IconContentFetcher {
40
41
  return "";
41
42
  }
42
43
  const url = `https://static.parastorage.com/services/wix-ui-icons-common/dist/icons/${theme}/${category}/${name}.${hash}.json`;
43
- const request = fetch(url, {
44
- signal: createTimeoutSignal(ABORT_SIGNAL_TIMEOUT)
45
- }).then((res) => {
46
- if (!res.ok) {
47
- throw new Error(`Failed to fetch icon: ${res.status}`);
44
+ const fetchContent = async (attemptsRemaining) => {
45
+ try {
46
+ const response = await fetch(url, {
47
+ signal: createTimeoutSignal(ABORT_SIGNAL_TIMEOUT)
48
+ });
49
+ if (!response.ok) {
50
+ throw new Error(`Failed to fetch icon: ${response.status}`);
51
+ }
52
+ return await response.json();
53
+ } catch (error) {
54
+ if (attemptsRemaining > 1 && isTransientError(error)) {
55
+ return fetchContent(attemptsRemaining - 1);
56
+ }
57
+ throw error;
48
58
  }
49
- return res.json();
50
- }).then((data) => {
59
+ };
60
+ const request = fetchContent(2).then((data) => {
51
61
  this.cache.set(cacheKey, data.content);
52
62
  this.pendingRequests.delete(cacheKey);
53
63
  }).catch((error) => {
54
64
  this.pendingRequests.delete(cacheKey);
55
- this.failedRequests.add(cacheKey);
65
+ if (!isTransientError(error)) {
66
+ this.failedRequests.add(cacheKey);
67
+ }
56
68
  console.error(`Error fetching icon ${name}:`, error);
57
69
  throw error;
58
70
  });