Skip to content

Commit 036f7aa

Browse files
chore(ssr): add prewarm diagnostics (ss/lsof) when remoteEntry timeouts occur; improves CI triage
1 parent 69474fa commit 036f7aa

File tree

7 files changed

+58
-5
lines changed

7 files changed

+58
-5
lines changed

federated-css-react-ssr/shell-apps/css-jss/server/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ async function waitUrl(url, timeout = 300000) {
1616
} catch (_) {}
1717

1818
if (Date.now() - start > timeout) {
19+
// extra diagnostics in CI: try to print which ports are listening
20+
try {
21+
const { execSync } = require('node:child_process');
22+
const ss = execSync(`ss -ltnp | grep :${new URL(url).port} || true`, { stdio: ['ignore','pipe','ignore'] }).toString().trim();
23+
if (ss) console.log(`[prewarm] port diag ${new URL(url).port}: ${ss}`);
24+
} catch (e) {}
1925
throw new Error(`prewarm timeout for ${url}`);
2026
}
2127
await new Promise(r => setTimeout(r, 5000));

federated-css-react-ssr/shell-apps/css-scss/server/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ async function waitUrl(url, timeout = 300000) {
1212
const res = await fetch(url);
1313
if (res.ok) return;
1414
} catch (_) {}
15-
if (Date.now() - start > timeout) throw new Error(`prewarm timeout for ${url}`);
15+
if (Date.now() - start > timeout) {
16+
try {
17+
const { execSync } = require('node:child_process');
18+
const ss = execSync(`ss -ltnp | grep :${new URL(url).port} || true`, { stdio: ['ignore','pipe','ignore'] }).toString().trim();
19+
if (ss) console.log(`[prewarm] port diag ${new URL(url).port}: ${ss}`);
20+
} catch {}
21+
throw new Error(`prewarm timeout for ${url}`);
22+
}
1623
await new Promise(r => setTimeout(r, 5000));
1724
}
1825
}

federated-css-react-ssr/shell-apps/jss-styled-components-css-module/server/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ async function waitUrl(url, timeout = 300000) {
1212
const res = await fetch(url);
1313
if (res.ok) return;
1414
} catch (_) {}
15-
if (Date.now() - start > timeout) throw new Error(`prewarm timeout for ${url}`);
15+
if (Date.now() - start > timeout) {
16+
try {
17+
const { execSync } = require('node:child_process');
18+
const ss = execSync(`ss -ltnp | grep :${new URL(url).port} || true`, { stdio: ['ignore','pipe','ignore'] }).toString().trim();
19+
if (ss) console.log(`[prewarm] port diag ${new URL(url).port}: ${ss}`);
20+
} catch {}
21+
throw new Error(`prewarm timeout for ${url}`);
22+
}
1623
await new Promise(r => setTimeout(r, 5000));
1724
}
1825
}

federated-css-react-ssr/shell-apps/jss-styled-components/server/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ async function waitUrl(url, timeout = 300000) {
1212
const res = await fetch(url);
1313
if (res.ok) return;
1414
} catch (_) {}
15-
if (Date.now() - start > timeout) throw new Error(`prewarm timeout for ${url}`);
15+
if (Date.now() - start > timeout) {
16+
try {
17+
const { execSync } = require('node:child_process');
18+
const ss = execSync(`ss -ltnp | grep :${new URL(url).port} || true`, { stdio: ['ignore','pipe','ignore'] }).toString().trim();
19+
if (ss) console.log(`[prewarm] port diag ${new URL(url).port}: ${ss}`);
20+
} catch {}
21+
throw new Error(`prewarm timeout for ${url}`);
22+
}
1623
await new Promise(r => setTimeout(r, 5000));
1724
}
1825
}

federated-css-react-ssr/shell-apps/less-scss/server/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ async function waitUrl(url, timeout = 300000) {
1212
const res = await fetch(url);
1313
if (res.ok) return;
1414
} catch (_) {}
15-
if (Date.now() - start > timeout) throw new Error(`prewarm timeout for ${url}`);
15+
if (Date.now() - start > timeout) {
16+
try {
17+
const { execSync } = require('node:child_process');
18+
const ss = execSync(`ss -ltnp | grep :${new URL(url).port} || true`, { stdio: ['ignore','pipe','ignore'] }).toString().trim();
19+
if (ss) console.log(`[prewarm] port diag ${new URL(url).port}: ${ss}`);
20+
} catch {}
21+
throw new Error(`prewarm timeout for ${url}`);
22+
}
1623
await new Promise(r => setTimeout(r, 5000));
1724
}
1825
}

federated-css-react-ssr/shell-apps/scss-tailwind-css/server/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ async function waitUrl(url, timeout = 300000) {
1212
const res = await fetch(url);
1313
if (res.ok) return;
1414
} catch (_) {}
15-
if (Date.now() - start > timeout) throw new Error(`prewarm timeout for ${url}`);
15+
if (Date.now() - start > timeout) {
16+
try {
17+
const { execSync } = require('node:child_process');
18+
const ss = execSync(`ss -ltnp | grep :${new URL(url).port} || true`, { stdio: ['ignore','pipe','ignore'] }).toString().trim();
19+
if (ss) console.log(`[prewarm] port diag ${new URL(url).port}: ${ss}`);
20+
} catch {}
21+
throw new Error(`prewarm timeout for ${url}`);
22+
}
1623
await new Promise(r => setTimeout(r, 5000));
1724
}
1825
}

federated-css/scripts/start-all.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ function forceKillPort(port) {
2424
try { execSync(`fuser -k ${port}/tcp`, { stdio: 'ignore' }); } catch {}
2525
}
2626

27+
function diagnosePort(port, label) {
28+
try {
29+
const ssout = execSync(`ss -ltnp | grep :${port} || true`, { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
30+
if (ssout) console.log(`[federated-css] diag ${label} port ${port}: ${ssout}`);
31+
} catch {}
32+
try {
33+
const lsofout = execSync(`lsof -nPiTCP -sTCP:LISTEN | grep :${port} || true`, { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
34+
if (lsofout) console.log(`[federated-css] diag ${label} port ${port} (lsof): ${lsofout}`);
35+
} catch {}
36+
}
37+
2738
async function ensurePortFree(port, timeoutMs = 15000) {
2839
const start = Date.now();
2940
while (Date.now() - start < timeoutMs) {
@@ -225,6 +236,7 @@ async function main() {
225236
} catch (error) {
226237
lastError = error;
227238
console.warn(`[federated-css] ${label} failed to start: ${error.message}`);
239+
diagnosePort(port, label);
228240
removeProc(proc);
229241
try {
230242
proc.kill('SIGTERM');

0 commit comments

Comments
 (0)