fix(preview): add 60-second grace period before marking freshly booted servers as zombies to prevent aggressive 502 teardowns
This commit is contained in:
@@ -126,6 +126,7 @@ export default function PreviewTab() {
|
||||
if (primaryRunning || primaryStarting) return; // already up or already starting
|
||||
|
||||
ensureCalledRef.current = true;
|
||||
setEnsureStatus("calling");
|
||||
|
||||
fetch(`/api/projects/${projectId}/dev-server/ensure`, {
|
||||
method: "POST",
|
||||
@@ -144,7 +145,14 @@ export default function PreviewTab() {
|
||||
}
|
||||
})
|
||||
.catch(() => setEnsureStatus("error"));
|
||||
}, [loading, anatomy, primaryRunning, primaryStarting, projectId]);
|
||||
}, [
|
||||
loading,
|
||||
anatomy,
|
||||
primaryRunning,
|
||||
primaryStarting,
|
||||
projectId,
|
||||
refreshKey,
|
||||
]);
|
||||
|
||||
const [iframeSrc, setIframeSrc] = useState<string | null>(null);
|
||||
const iframeDomRef = useRef<HTMLIFrameElement | null>(null);
|
||||
|
||||
@@ -825,6 +825,14 @@ async function loadPreviews(projectId: string): Promise<Preview[]> {
|
||||
ping.status === 504 ||
|
||||
ping.status === 404
|
||||
) {
|
||||
// Give freshly booted servers a 60-second grace period before murdering them.
|
||||
// Traefik sometimes returns 502 for a few seconds right after the internal probe succeeds.
|
||||
const ageMs = Date.now() - new Date(r.started_at).getTime();
|
||||
if (ageMs < 60000) {
|
||||
activePreviews.push(r);
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn(
|
||||
`[anatomy] Preview zombie detected for ${r.preview_url} (HTTP ${ping.status}). Marking stopped.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user