From 717877db3feea710eb45b3dddc7da342b9d61d17 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Fri, 9 Oct 2026 21:21:13 +1000 Subject: [PATCH] Fix flakey cypress test --- test/cypress/e2e/api/AccessListHostToggle.cy.js | 4 ++++ test/cypress/plugins/backendApi/client.mjs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/test/cypress/e2e/api/AccessListHostToggle.cy.js b/test/cypress/e2e/api/AccessListHostToggle.cy.js index b566a3a98..ee1bee0dc 100644 --- a/test/cypress/e2e/api/AccessListHostToggle.cy.js +++ b/test/cypress/e2e/api/AccessListHostToggle.cy.js @@ -192,7 +192,11 @@ describe('Access Lists across Proxy Host disable/enable', () => { expect(data).to.be.equal(true); }); + // Each delete signals an nginx reload and returns immediately. A request + // made while the workers are being swapped can be reset by the nginx + // serving the API (502 from squid), so let each reload settle first. [authListId, clientListId].forEach((id) => { + cy.wait(1500); cy.task('backendApiDelete', { token: token, path: `/api/nginx/access-lists/${id}`, diff --git a/test/cypress/plugins/backendApi/client.mjs b/test/cypress/plugins/backendApi/client.mjs index 78618abb2..5c0daa5c0 100644 --- a/test/cypress/plugins/backendApi/client.mjs +++ b/test/cypress/plugins/backendApi/client.mjs @@ -1,3 +1,4 @@ +import http from "node:http"; import axios from "axios"; import logger from "./logger.mjs"; @@ -8,6 +9,10 @@ const BackendApi = function (config, token) { this.axios = axios.create({ baseURL: config.baseUrl, timeout: 90000, + // Don't reuse sockets: a pooled keep-alive connection that squid or the + // backend has since closed fails with a 502 (ERR_READ_ERROR 104), which + // made tests flaky. + httpAgent: new http.Agent({ keepAlive: false }), }); };