DSingh0304 commented on code in PR #3258:
URL: https://github.com/apache/apisix-dashboard/pull/3258#discussion_r2548557043


##########
src/apis/upstreams.ts:
##########
@@ -55,17 +55,36 @@ export const putUpstreamReq = (
 };
 
 export const deleteAllUpstreams = async (req: AxiosInstance) => {
-  const totalRes = await getUpstreamListReq(req, {
-    page: 1,
-    page_size: PAGE_SIZE_MIN,
-  });
+  const retry = async <T>(fn: () => Promise<T>, times = 3, delay = 500) => {
+    let lastErr: unknown;
+    for (let i = 0; i < times; i++) {
+      try {
+        return await fn();
+      } catch (err) {
+        lastErr = err;
+        // small backoff between attempts
+         
+        await new Promise((r) => setTimeout(r, delay));
+      }
+    }
+    throw lastErr;
+  };
+
+  const totalRes = await retry(() =>
+    getUpstreamListReq(req, {
+      page: 1,
+      page_size: PAGE_SIZE_MIN,
+    })
+  );

Review Comment:
   Done...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to