feat: keep containers alive for 60s of inactivity instead of killing them on disconnect

This commit is contained in:
James Murdza
2024-09-30 03:41:33 -07:00
parent 09b3cf1862
commit 01fb3ab921
2 changed files with 22 additions and 20 deletions

View File

@ -59,6 +59,13 @@ export default function CodeEditor({
}
}, [socket, userData.id, sandboxData.id, setUserAndSandboxId])
// This heartbeat is critical to preventing the E2B sandbox from timing out
useEffect(() => {
// 10000 ms = 10 seconds
const interval = setInterval(() => socket?.emit("heartbeat"), 10000);
return () => clearInterval(interval);
}, [socket]);
//Preview Button state
const [isPreviewCollapsed, setIsPreviewCollapsed] = useState(true)
const [disableAccess, setDisableAccess] = useState({