fix(agent): increase dev server readiness probe timeout to 300s to accommodate slow Next.js cold boots and prevent premature AI loop restarts

This commit is contained in:
2026-05-15 16:59:10 -07:00
parent 7832e83542
commit 08ea31c39e

View File

@@ -722,13 +722,13 @@ export async function probeDevServerReadiness(
port: number,
): Promise<void> {
await ensureDevServersTable();
// Up to ~120s: Next/Vite cold compile often exceeds 60s on small hosts.
// Up to ~300s: Next/Vite cold compile + potential npm installs can take a while.
// We accept any HTTP response (including 404/500) as "listening" — only
// connection failures stay 000 — because `curl -sf` falsely failed when `/`
// returned a dev error page before the app was fully ready.
const probeCmd =
`last_code=000; ` +
`for i in $(seq 1 120); do ` +
`for i in $(seq 1 300); do ` +
`for path in / ''; do ` +
`code=$(curl -sS -o /dev/null -w '%{http_code}' --max-time 2 --connect-timeout 2 ` +
`"http://127.0.0.1:${port}$path" 2>/dev/null || printf '000'); ` +
@@ -737,15 +737,15 @@ export async function probeDevServerReadiness(
`done; ` +
`sleep 1; done; ` +
`echo "PROBE_FAIL last_code=$last_code port=${port}"; ` +
`echo "PROBE_FAIL ps=$(ps aux | grep -E 'node|npm|next|vite' | grep -v grep | head -3 | tr '\n' '|')"; ` +
`echo "PROBE_FAIL log_tail=$(tail -20 /var/log/vibn-dev/${serverId}.log 2>/dev/null | tr '\n' '|' | head -c 2000)"; ` +
`echo "PROBE_FAIL ps=$(ps aux | grep -E 'node|npm|next|vite' | grep -v grep | head -3 | tr '\\n' '|')"; ` +
`echo "PROBE_FAIL log_tail=$(tail -20 /var/log/vibn-dev/${serverId}.log 2>/dev/null | tr '\\n' '|' | head -c 2000)"; ` +
`exit 1`;
try {
const r = await execInDevContainer({
projectId,
command: probeCmd,
timeoutMs: 130_000,
timeoutMs: 310_000,
});
if (r.exitCode === 0) {
await query(