Merge pull request #582 from stefandevo/fix/e2e-response-disposal-race

fix: prevent response disposal race condition in E2E test
This commit is contained in:
Shirone
2026-01-19 00:02:04 +00:00
committed by GitHub

View File

@@ -84,18 +84,24 @@ test.describe('Open Project', () => {
// Intercept settings API BEFORE any navigation to prevent restoring a currentProject
// AND inject our test project into the projects list
await page.route('**/api/settings/global', async (route) => {
const response = await route.fetch();
// 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 response;
try {
response = await route.fetch();
} catch {
// If fetch fails, continue with original request
await route.continue();
return;
}
let json;
try {
json = JSON.parse(body.toString());
json = await response.json();
} catch {
json = {};
// If response is disposed, continue with original request
await route.continue();
return;
}
if (json.settings) {
// Remove currentProjectId to prevent restoring a project
json.settings.currentProjectId = null;
@@ -115,11 +121,7 @@ test.describe('Open Project', () => {
json.settings.projects = [testProject, ...existingProjects];
}
}
await route.fulfill({
status: status,
headers: headers,
json,
});
await route.fulfill({ response, json });
});
// Now navigate to the app