Copilot commented on code in PR #3305:
URL: https://github.com/apache/apisix-dashboard/pull/3305#discussion_r2896983272


##########
e2e/utils/req.ts:
##########
@@ -27,30 +27,66 @@ export const getPlaywrightRequestAdapter = (
   ctx: APIRequestContext
 ): AxiosAdapter => {
   return async (config) => {
-    const { url, data, baseURL } = config;
+    const { url, data, baseURL, method } = config;
     if (typeof url === 'undefined') {
       throw new Error('Need to provide a url');
     }
 
     type Payload = Parameters<APIRequestContext['fetch']>[1];
     const payload: Payload = {
       headers: config.headers,
-      method: config.method,
-      failOnStatusCode: true,
+      method,
+      failOnStatusCode: false,
       data,
     };
     const urlWithBase = `${baseURL}${url}`;
     const res = await ctx.fetch(urlWithBase, payload);
+    const status = res.status();
 
-    try {
+    // Idempotent DELETE: Treat 404 as 200 OK
+    if (method?.toLowerCase() === 'delete' && status === 404) {
+      console.warn(`[e2eReq] Ignored 404 on DELETE for ${urlWithBase}, 
treating as 200 OK.`);
       return {
+        data: {},
+        status: 200,
+        statusText: 'OK',
+        headers: {},
+        config,
+      };
+    }

Review Comment:
   In the idempotent DELETE branch (404 treated as OK), the Playwright 
APIResponse (`res`) is returned without being disposed. This bypasses the 
`finally { await res.dispose(); }` and can leak resources/handles across the 
test run. Dispose the response before returning (or restructure to keep all 
returns inside the try/finally).



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