Skip to content

Commit 8d1c7e0

Browse files
committed
fix(e2e): use 20s goto timeout and Node.js http for diagnostics to survive test timeout
1 parent edaed5c commit 8d1c7e0

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

crates/web/ui/e2e/helpers.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function navigateAndWait(page, path) {
9595
if (attempt > 0) {
9696
await page.goto("about:blank").catch(() => {});
9797
}
98-
await page.goto(path, { waitUntil: "domcontentloaded" });
98+
await page.goto(path, { waitUntil: "domcontentloaded", timeout: 20_000 });
9999
await expectPageContentMounted(page);
100100
return pageErrors;
101101
} catch (error) {
@@ -114,15 +114,45 @@ async function navigateAndWait(page, path) {
114114
var healthOk = "unknown";
115115
try {
116116
var baseURL = testInfo.project.use?.baseURL || "http://127.0.0.1";
117-
var healthRes = await page.request.get(`${baseURL}/health`, { timeout: 3_000 });
118-
healthOk = healthRes.ok() ? await healthRes.text() : `status=${healthRes.status()}`;
117+
// Use http module directly — page.request dies when test timeout kills the context
118+
var http = require("node:http");
119+
healthOk = await new Promise((resolve) => {
120+
var req = http.get(`${baseURL}/health`, { timeout: 3000 }, (res) => {
121+
var body = "";
122+
res.on("data", (d) => (body += d));
123+
res.on("end", () => resolve(`${res.statusCode} ${body.slice(0, 200)}`));
124+
});
125+
req.on("error", (e) => resolve(`error: ${e.message}`));
126+
req.on("timeout", () => {
127+
req.destroy();
128+
resolve("timeout");
129+
});
130+
});
119131
} catch (he) {
120132
healthOk = `error: ${he.message?.slice(0, 100)}`;
121133
}
134+
// Also try fetching the SPA page directly to see if server responds
135+
var pageHttpOk = "unknown";
136+
try {
137+
pageHttpOk = await new Promise((resolve) => {
138+
var req = http.get(`${baseURL}${path}`, { timeout: 3000 }, (res) => {
139+
resolve(`${res.statusCode} content-length=${res.headers["content-length"] || "?"}`);
140+
res.resume();
141+
});
142+
req.on("error", (e) => resolve(`error: ${e.message}`));
143+
req.on("timeout", () => {
144+
req.destroy();
145+
resolve("timeout");
146+
});
147+
});
148+
} catch (pe) {
149+
pageHttpOk = `exception: ${pe.message?.slice(0, 100)}`;
150+
}
122151
var diag = [
123152
`navigateAndWait failed for ${path} after ${attempt + 1} attempts`,
124153
`page.url(): ${page.url()}`,
125154
`health: ${healthOk}`,
155+
`page-http: ${pageHttpOk}`,
126156
`responses: ${JSON.stringify(responses.slice(0, 5))}`,
127157
`console: ${JSON.stringify(consoleMessages.slice(0, 10))}`,
128158
`error: ${error.message?.slice(0, 200)}`,

0 commit comments

Comments
 (0)