From f68aee6a197f6a739c29257c1fa4fb7f326a15f3 Mon Sep 17 00:00:00 2001 From: DhanushSantosh Date: Sun, 18 Jan 2026 19:29:32 +0530 Subject: [PATCH] fix: prevent response disposal race condition in E2E test --- .../tests/projects/open-existing-project.spec.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/ui/tests/projects/open-existing-project.spec.ts b/apps/ui/tests/projects/open-existing-project.spec.ts index 51772a25..cd9beb98 100644 --- a/apps/ui/tests/projects/open-existing-project.spec.ts +++ b/apps/ui/tests/projects/open-existing-project.spec.ts @@ -85,7 +85,17 @@ test.describe('Open Project', () => { // AND inject our test project into the projects list await page.route('**/api/settings/global', async (route) => { const response = await route.fetch(); - const json = await response.json(); + // Immediately consume the body to prevent disposal issues + const bodyPromise = response.body(); + const status = response.status(); + const headers = response.headers(); + const body = await bodyPromise; + let json; + try { + json = JSON.parse(body.toString()); + } catch { + json = {}; + } if (json.settings) { // Remove currentProjectId to prevent restoring a project json.settings.currentProjectId = null; @@ -106,8 +116,8 @@ test.describe('Open Project', () => { } } await route.fulfill({ - status: response.status(), - headers: response.headers(), + status: status, + headers: headers, json, }); });