Preview proxy tuneup

This commit is contained in:
2026-02-22 16:00:52 +00:00
parent ca45301e3e
commit a8aba2aee2
2 changed files with 60 additions and 18 deletions
@@ -87,6 +87,24 @@ export const PreviewProvider = ({ children }: PreviewProviderProps) => {
return () => { cancelled = true; };
}, [slug]);
// Poll status while a server is supposedly running — auto-restart if it died (e.g. idle timeout)
useEffect(() => {
if (!slug || !url) return;
const interval = setInterval(async () => {
try {
const status = await client.get<DevServerStatus>(`/dev-server/status?slug=${encodeURIComponent(slug)}`);
if (!status.running) {
startServer(slug);
}
} catch {
// ignore transient failures
}
}, 30_000);
return () => clearInterval(interval);
}, [slug, url]);
return (
<PreviewContext
value={{