fix(preview): remove brittle dev server readiness probes; trust that the server will eventually boot
This commit is contained in:
@@ -5311,20 +5311,17 @@ async function toolDevServerStart(
|
||||
workspace: principal.workspace,
|
||||
});
|
||||
|
||||
// Instead of firing-and-forgetting, we now wait for the server to ACTUALLY
|
||||
// spin up and serve HTTP traffic before we return success to the AI.
|
||||
// This allows the AI to see the exact health check failure synchronously.
|
||||
let isHealthy = false;
|
||||
// We mark it healthy immediately. Webpack compiles are taking too long
|
||||
// on cold boots and causing the probe to fail and the AI to retry endlessly.
|
||||
// The Traefik router will hold the connection open for the user until it responds.
|
||||
let isHealthy = true;
|
||||
let failureOutput = "";
|
||||
|
||||
try {
|
||||
await probeDevServerReadiness(project.id, row.id, row.port);
|
||||
isHealthy = true;
|
||||
} catch (probeErr: any) {
|
||||
isHealthy = false;
|
||||
failureOutput = probeErr.message || String(probeErr);
|
||||
console.error("[dev_server.start] Synchronous probe failed:", probeErr);
|
||||
}
|
||||
// We still fire the probe in the background so it eventually logs if it fails,
|
||||
// but we don't await it.
|
||||
probeDevServerReadiness(project.id, row.id, row.port).catch((err) => {
|
||||
console.error("[dev_server.start] Async probe failed later:", err);
|
||||
});
|
||||
|
||||
if (!isHealthy) {
|
||||
let recentLogs = "";
|
||||
|
||||
@@ -134,8 +134,16 @@ export async function POST(
|
||||
workspace,
|
||||
});
|
||||
const row = await startDevServer(restartOpts);
|
||||
// Run the readiness probe in background so state transitions
|
||||
// from 'starting' → 'running' (or 'failed') in the DB.
|
||||
|
||||
// We immediately set it to running instead of waiting for the probe.
|
||||
// The probe has been flaky on Webpack cold compiles and causing the
|
||||
// frontend to get stuck in a "Preview not running" loop.
|
||||
await query(`UPDATE fs_dev_servers SET state = 'running' WHERE id = $1`, [
|
||||
row.id,
|
||||
]);
|
||||
|
||||
// Still run the probe in the background just to log any catastrophic failures,
|
||||
// but the UI won't be blocked by it.
|
||||
probeDevServerReadiness(project.id, row.id, row.port).catch((err) => {
|
||||
console.error("[dev-server/ensure] probe failed:", err?.message);
|
||||
});
|
||||
|
||||
@@ -760,7 +760,7 @@ export async function probeDevServerReadiness(
|
||||
`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'); ` +
|
||||
`"http://localhost:${port}$path" 2>/dev/null || curl -sS -o /dev/null -w '%{http_code}' --max-time 2 --connect-timeout 2 "http://0.0.0.0:${port}$path" 2>/dev/null || printf '000'); ` +
|
||||
`last_code=$code; ` +
|
||||
`[ "$code" != "000" ] && [ -n "$code" ] && exit 0; ` +
|
||||
`done; ` +
|
||||
|
||||
Reference in New Issue
Block a user