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


##########
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
+         
+        await new Promise((r) => setTimeout(r, delay));
+      }
+    }
+    throw lastErr;
+  };
+
+  const totalRes = await retry(() =>
+    getUpstreamListReq(req, {
+      page: 1,
+      page_size: PAGE_SIZE_MIN,
+    })
+  );

Review Comment:
   Added retry logic to handle transient 500 errors during E2E test cleanup in 
CI. When tests rapidly create/delete resources, the backend can temporarily 
fail. The retry wrapper (with backoff) and 404 handling ensure cleanup doesn't 
fail due to these transient issues or race conditions in parallel test 
execution.



-- 
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